<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>Three till Seven &#187; Perl</title>
	<atom:link href="http://www.3till7.net/category/techy/perl/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.3till7.net</link>
	<description>A geek's personal domain.</description>
	<pubDate>Sat, 16 Aug 2008 19:09:44 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
	<language>en</language>
			<item>
		<title>using Perl and Apache on OS X</title>
		<link>http://www.3till7.net/2007/03/22/perl-apache-and-os-x/</link>
		<comments>http://www.3till7.net/2007/03/22/perl-apache-and-os-x/#comments</comments>
		<pubDate>Thu, 22 Mar 2007 15:08:20 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
		
		<category><![CDATA[OS X]]></category>

		<category><![CDATA[Perl]]></category>

		<category><![CDATA[Web development]]></category>

		<category><![CDATA[apache]]></category>

		<guid isPermaLink="false">http://www.3till7.net/2007/03/22/perl-apache-and-os-x/</guid>
		<description><![CDATA[I&#8217;m trying to do some work with a Perl app on my Powerbook but I was unable to get any Perl scripts to execute from my local server.  At first, I was getting just the source of the Perl files spit back at me.  I followed a few tutorials about getting /etc/httpd/httpd.conf set [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m trying to do some work with a Perl app on my Powerbook but I was unable to get any Perl scripts to execute from my local server.  At first, I was getting just the source of the Perl files spit back at me.  I followed a few <a href="http://www.cgi101.com/learn/connect/mac.html">tutorials</a> about getting /etc/httpd/httpd.conf set up, but then I kept getting 403 Forbidden errors when I tried to access .pl or .cgi files in my browser.  I checked /var/log/httpd/error_log and saw:</p>
<blockquote><p>[Thu Mar 22 10:55:17 2007] [error] [client 127.0.0.1] Options ExecCGI is off in this directory: /Users/sarah/Sites/test.cgi</p></blockquote>
<p>I thought to myself, &#8220;B.S.!  ExecCGI is on for that directory!&#8221;  Sure enough, in my httpd.conf file, I had:</p>
<blockquote><p><code>&lt;Directory /Users/*/Sites&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;AllowOverride FileInfo AuthConfig Limit<br />
&nbsp;&nbsp;&nbsp;&nbsp;Options <strong>ExecCGI</strong> MultiViews Indexes SymLinksIfOwnerMatch Includes<br />
&nbsp;&nbsp;&nbsp;&nbsp;DirectoryIndex index.htm index.html index.cgi<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;Limit GET POST OPTIONS PROPFIND&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Order allow,deny<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Allow from all<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/Limit&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;LimitExcept GET POST OPTIONS PROPFIND&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Order deny,allow<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Deny from all<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/LimitExcept&gt;<br />
&lt;/Directory&gt;</code></p></blockquote>
<p>I had restarted Apache with <code>sudo apachectl graceful</code>, so what was up?  Then I noticed something else in error_log:</p>
<blockquote><p>Processing config directory: /private/etc/httpd/users/*.conf<br />
Processing config file: /private/etc/httpd/users/sarah.conf</p></blockquote>
<p>What was this /private/etc/httpd/users/sarah.conf that it was talking about?  I had never created this file.  I checked and it certainly existed.  It also had an Options line without ExecCGI&mdash;bingo!  I simply removed the file because it was just redefining what I had already specified in httpd.conf for Users/*/Site directories (shown above).  I then restarted Apache and voila, my scripts worked.  :)  I can only assume something auto-generated that file, because it certainly wasn&#8217;t me.</p>
<p>Other things to check if you&#8217;re still seeing the source of your scripts or getting a 403 error:</p>
<ul>
<li>Is your script executable?  Chmod it to 755 to be sure.</li>
<li>Ensure these lines are uncommented in your /etc/httpd/httpd.conf (or whatever your Apache config file is):
<ul>
<li><code>LoadModule cgi_module         libexec/httpd/mod_cgi.so</code></li>
<li><code>LoadModule perl_module        libexec/httpd/libperl.so</code></li>
<li><code>AddModule mod_cgi.c</code></li>
<li><code>AddModule mod_perl.c</code></li>
<li><code>AddHandler cgi-script .cgi .pl</code></li>
</ul>
</li>
<li>Be sure to restart Apache after making any config file changes.  You can do this via Terminal with the command <code>sudo apachectl graceful</code>, which will prompt you for your password, or via System Preferences &gt; Sharing, where you Stop &#8220;Personal Web Sharing&#8221; and Start it again.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.3till7.net/2007/03/22/perl-apache-and-os-x/feed/</wfw:commentRss>
		</item>
		<item>
		<title>extensionChanger.pl</title>
		<link>http://www.3till7.net/2005/12/18/extensionchangerpl/</link>
		<comments>http://www.3till7.net/2005/12/18/extensionchangerpl/#comments</comments>
		<pubDate>Sun, 18 Dec 2005 18:38:00 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
		
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://www.3till7.net/?p=1004</guid>
		<description><![CDATA[This script will rename all files with one extension to another extension.  Example:  all files in a given directory that end with .php will be renamed to end with .txt.


Download the program and instructions

The only change you might have to make is if you&#8217;re on a Linux machine and Perl is not at [...]]]></description>
			<content:encoded><![CDATA[<p>This script will rename all files with one extension to another extension.  Example:  all files in a given directory that end with .php will be renamed to end with .txt.<br />
<!--mizore--></p>
<ul>
<li><a href="/wp-content/code/perl/extensionChanger.zip">Download</a> the program and instructions</li>
</ul>
<p>The only change you might have to make is if you&#8217;re on a Linux machine and Perl is not at /usr/bin/perl, but somewhere else, in which case you would need to change the first line to contain the proper path.  I&#8217;ve not tested this program on a Windows box.</p>
<p><code>#!/usr/bin/perl</code><br />
<code># Renames file extensions</code><br />
<code>#</code><br />
<code># Syntax:</code><br />
<code>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;perl extensionChanger.pl --from=FIRST_EXTENSION --to=SECOND_EXTENSION</code><br />
<code># Example use:</code><br />
<code># &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;perl extensionChanger.pl --from=html --to=php</code><br />
<code># Optional:</code><br />
<code># &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Specify a directory to work in.  Defaults to PWD.</code><br />
<code># &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--dir=DIRECTORY</code><br />
<code># Example use:</code><br />
<code># &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;perl extensionChanger.pl --from=exe --to=pl --dir=tmp</code><br />
<code>#</code><br />
<code># Sarah; 2005-12-18</code></p>
<p><code>use Getopt::Long;</code><br />
<code>GetOptions(</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"from=s" => \$ext1,</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"to=s" => \$ext2,</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"dir=s" => \$dir</code><br />
<code>);</code></p>
<p><code>if ($ext1 eq "" or $ext2 eq "") {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print "Syntax:\n";</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print "\tperl extensionChanger.pl --from=FIRST_EXTENSION --to=SECOND_EXTENSION\n\n";</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print "Example:\n";</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print "\tperl extensionChanger.pl --from=txt --to=php\n\n";</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print "Optional:\n";</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print "\tSpecify a directory to work in.  Defaults to PWD.\n";</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print "\t--dir=DIRECTORY\n\n";</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print "Example:\n";</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print "\tperl extensionChanger.pl --from=exe --to=pl --dir=tmp\n";</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit;</code><br />
<code>} else {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($dir eq "") {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$dir = ".";</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</code></p>
<p><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;opendir(DIR, $dir) || die "Could not open directory for reading.";</code></p>
<p><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# Get an array of all files with the old extension that are in the given directory</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@files = grep(/\.$ext1$/, readdir(DIR));</code></p>
<p><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($files[0] eq &#8220;&#8221;) {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print "There are no files of extension '$ext1' ";</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($dir eq ".") {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print "in PWD";</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print "in $dir";</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print ".\n";</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# For every file with the old extension in the given directory...</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foreach $file (@files) {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print "$file ";</code></p>
<p><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($dir ne ".") {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print "in $dir/ ";</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</code></p>
<p><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# Remove the current extension from the $file variable</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$file =~ s/\.$ext1//g;</code></p>
<p><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# Rename the file to have the new extension</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$error = `mv $dir/$file.$ext1 $dir/$file.$ext2`;</code></p>
<p><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print "is now $file.$ext2\n";</code></p>
<p><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# If there were errors, print them</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($error ne "") {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print "E: $error\n";</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;closedir(DIR);</code><br />
<code>}</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.3till7.net/2005/12/18/extensionchangerpl/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
