<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Three till Seven &#187; Perl</title>
	<atom:link href="http://www.3till7.net/tag/perl/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.3till7.net</link>
	<description>Programming, espresso, and grumbling.</description>
	<lastBuildDate>Sun, 13 Jun 2010 15:26:58 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>a busy day, filled with Perlnanigans</title>
		<link>http://www.3till7.net/2007/04/19/a-busy-day-filled-with-perlnanigans/</link>
		<comments>http://www.3till7.net/2007/04/19/a-busy-day-filled-with-perlnanigans/#comments</comments>
		<pubDate>Fri, 20 Apr 2007 00:21:03 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[Daily life]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[cooking]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.3till7.net/2007/04/19/a-busy-day-filled-with-perlnanigans/</guid>
		<description><![CDATA[Today was one of those kick-ass days that went by in a whirlwind.  I had a discrete math test at 9:30 this morning and I think I did really well on it.  It seemed only slightly harder than his last one, which was the easiest test he&#8217;d given us.  After that, I [...]]]></description>
			<content:encoded><![CDATA[<p>Today was one of those kick-ass days that went by in a whirlwind.  I had a discrete math test at 9:30 this morning and I think I did really well on it.  It seemed only slightly harder than his last one, which was the easiest test he&#8217;d given us.  After that, I fiddled in Photoshop on my lunch break, working on another layout idea.  At 12:30, I had my algorithms lecture, which was pretty good today because we got help from a geeky computer science grad student on our second programming assignment.  Neil was the grad, and he&#8217;s also someone I work alongside in Dr. J&#8217;s lab.  He&#8217;s one of those &uuml;ber geeks that just tickle me to death because he&#8217;s the type that knows absolutely everything about C, Linux, Perl, math, and computer science theory.  People like that are these wonderful fountains of information and I love getting the opportunity to sit down with them and ask random questions about any and everything geeky.  My dad&#8217;s like that to me with Linux, open source, bash, and old computer hardware, then a coworker at Lexmark was like that with Linux, Perl, and C.  I think I admire people like that so much because that&#8217;s kind of my goal, to be a 1337 h4&#215;0r with lots of knowledge and skills in such areas.</p>
<p>Okay, away from that little tangent and back to my day.  So, after algorithms, I had biology, in which I semi-paid attention to his lecture on the history of life on earth and semi-read <a href="http://dubious.nu/forum/">Snark</a>.  I got to do a little research online for that in order to respond to a post about when one could shoot somebody and have legal recourse based on self defense.  My findings (all relevant to U.S. law only) pretty much told me what I already knew:  if you feel threatened, you have a right to defend yourself.</p>
<p>After biology, I went to work for two hours, and they were the quickest two hours ever because I got involved in some Perl work.  Because of the Apache setup on the machine I have to work on, which doesn&#8217;t have mod_perl enabled, I&#8217;ve had to split up the app between /var/www/html and /var/www/cgi-bin, with the HTML, PHP, CSS, and images in html/ and the Perl files and modules in cgi-bin/.  Today I set up a neat little config file that both the PHP and Perl can parse to determine where to redirect users (/cgi-bin/biodb or just /biodb, based on whether they&#8217;re going to a Perl file or a PHP file) as well as other basic options, such as the session name.  I&#8217;ve got both a testing and a &#8220;live&#8221; version of the app available, so the two need to not argue with each other over cookies, which use the session name variable, so each needs a different cookie name to peacefully coexist.  I love days where I just sit down and code for X hours straight, barely looking up.  The time flies by and I leave feeling very productive.</p>
<p>After getting out of work, I immediately came home and started cooking; I fixed <a href="http://allrecipes.com/Recipe/Shepherds-Pie/Detail.aspx">shepherd&#8217;s pie</a> for mine and Todd&#8217;s dinner.  I think it turned out very well, even if it did require a bit of work to begin with.  Gotta peel the potatoes, get them boiling, brown the beef, mix in the veggies and soups, and then spread everything out in a dish before you can begin to bake it and let it be.  I&#8217;m more of a &#8216;toss it in a pan and let it hang out&#8217; kind of girl, but if I have to nurse it to make a great dish, I&#8217;ll do it.  :)  I&#8217;ll definitely be making it again, because it was very filling and tasted creamy.  Todd and I each had two helpings, too, which was a good indication that the taste was agreeable.  I need to recommend it to my mom.</p>
<p>After dinner, Todd and I hit up the grocery, and now I&#8217;m relaxing at my place.  I figure I&#8217;ll play in Photoshop on my Powerbook while my PC updates Ubuntu to Feisty Fawn.  It&#8217;s going very slowly (I started the upgrade this morning) I imagine because everyone and their mama is upgrading to the latest and greatest.  Here&#8217;s hoping nothing goes wonky after the update.</p>
<p>Haha, a word popped into my head earlier as a result of my Perl work and because I was thinking about Super Troopers:  Perlnanigans.  You know, as a play on the word &#8217;shenanigans.&#8217;  It&#8217;s one of those ridiculous words that are so dumb they make you laugh, or at least it makes <em>me</em> laugh.  I can picture some cutesy little image of a person laughing on a t-shirt, with a talk bubble saying, &#8220;I&#8217;ve been up to some Perlnanigans o noes!!1&#8243;, something like that.  Hmm, I wonder if Jem would buy such a thing to add to her <a href="http://www.jemjabella.co.uk/personal/geek_tshirts.php" class="broken_link" >collection of geeky t-shirts</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.3till7.net/2007/04/19/a-busy-day-filled-with-perlnanigans/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>toilet paper holder engineering and Perl issues</title>
		<link>http://www.3till7.net/2007/04/13/toilet-paper-holder-engineering-and-perl-issues/</link>
		<comments>http://www.3till7.net/2007/04/13/toilet-paper-holder-engineering-and-perl-issues/#comments</comments>
		<pubDate>Fri, 13 Apr 2007 20:07:50 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[Daily life]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://www.3till7.net/2007/04/13/toilet-paper-holder-engineering-and-perl-issues/</guid>
		<description><![CDATA[How many engineers does it take to design a toilet paper holder?  You wouldn&#8217;t think such a seemingly simple device would be difficult, but it&#8217;s apparently impossible.  Think about it:  when you go to a public restroom and there&#8217;s the big container of toilet paper rolls in the stall, how often is [...]]]></description>
			<content:encoded><![CDATA[<p>How many engineers does it take to design a toilet paper holder?  You wouldn&#8217;t think such a seemingly simple device would be difficult, but it&#8217;s apparently impossible.  Think about it:  when you go to a public restroom and there&#8217;s the big container of toilet paper rolls in the stall, how often is there just the right amount of friction in pulling off the toilet paper?  For me, it&#8217;s always one of these two cases:</p>
<ol class="padded">
<li>You have to keep pulling at the toilet paper because it&#8217;s stuck, and you just keep ripping off one sheet at a time because the roll barely turns; or</li>
<li>You give a slight tug and you not only get all the toilet paper you need, but there&#8217;s also a little pile of it in the floor because there&#8217;s no stopping the spinning!</li>
</ol>
<p>I commented on this to Jess today as we were leaving Macy&#8217;s restroom.  This is why people like her and I (both in UK&#8217;s College of Engineering) have jobs, I tell you.</p>
<p>I&#8217;ve hit an annoyance with work, specifically with Perl and sessions.  Depending on how I change the application, it requires the user to log in twice before they&#8217;re authenticated, it lets them log in once but then going to any restricted area tosses them back to the login screen, or it logs them in on the first try but immediately puts them back at the login page.  It&#8217;s driving me nuts.  I keep thinking I have it fixed and then another permutation of the problem comes up.  I didn&#8217;t have any of this when I was developing on my Powerbook, on which I&#8217;m using mod_perl with Apache.  The system it&#8217;s on now is in Dr. Jaromczyk&#8217;s lab and it doesn&#8217;t use mod_perl.  I can&#8217;t change Apache on that machine because I don&#8217;t have permission; I might be able to get the admin to do it, but I want to exhaust other possibilities before doing so.  Initially the problem was that the session was getting deleted but the cookie was not.  Now the cookie gets deleted on logout as well as the session.  Then I thought the problem was that I was setting a cookie path other than &#8216;/&#8217;, the default, so I changed that, but there are still issues.  I&#8217;ll keep plugging away at it, I guess.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.3till7.net/2007/04/13/toilet-paper-holder-engineering-and-perl-issues/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<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 14:08:20 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[OS X]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://www.3till7.net/2007/03/22/perl-apache-and-os-x/</guid>
		<description><![CDATA[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--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.]]></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>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>fungal database project</title>
		<link>http://www.3till7.net/2007/02/24/fungal-database-project/</link>
		<comments>http://www.3till7.net/2007/02/24/fungal-database-project/#comments</comments>
		<pubDate>Sat, 24 Feb 2007 15:46:39 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[Daily life]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://www.3till7.net/2007/02/24/fungal-database-project/</guid>
		<description><![CDATA[Work has been going all right. I’m converting over an old Perl web interface to Rails. It seems so crazy to write a Perl web interface for a MySQL backend from scratch; the guy didn’t use any kind of framework. The project deals with bioinformatics, specifically a fungal database. The database itself is huge: 1.4G. [...]]]></description>
			<content:encoded><![CDATA[<p>Work has been going all right. I’m converting over an old Perl web interface to Rails. It seems so crazy to write a Perl web interface for a MySQL backend from scratch; the guy didn’t use any kind of framework. The project deals with bioinformatics, specifically a fungal database. The database itself is huge: 1.4G. I’ve been going through all the tables and figuring out what is and isn’t necessary. When the guy originally wrote it, the specs were being changed on him, so things are kind of hairy. For example, there’s a pe table and a programsexecuted table; I’m replacing them both with one table called executed_programs. I’m trying to stick with the Rails convention of plural table names, singular model names. So the model would be ExecutedProgram, hence why I flipped the words around. I’m supposed to be taking the project over, but the guy isn’t liking that I’m doing it in Rails. He said it needs to stay in Perl because all the biology people know Perl, and because some of the modules are written in Perl. I don’t think that’ll be a big deal. For one thing, I haven’t heard of the bio folks doing any of this coding on their own. Why else would they hire us? We’re the programmers! As for the Perl modules, if there’s not a Ruby version of them, I’ll figure out a way to incorporate the Perl version in there.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.3till7.net/2007/02/24/fungal-database-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>back in Rails work</title>
		<link>http://www.3till7.net/2007/02/09/back-in-rails-work/</link>
		<comments>http://www.3till7.net/2007/02/09/back-in-rails-work/#comments</comments>
		<pubDate>Fri, 09 Feb 2007 15:47:34 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[Daily life]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://www.3till7.net/2007/02/09/back-in-rails-work/</guid>
		<description><![CDATA[Classes have started again for the spring semester and I&#8217;m off my co-op, so I&#8217;m back in full-time classes. I do have to pay the bills, though, so I&#8217;m working for one of my professors. He called it &#8220;undergraduate research,&#8221; and it is kinda that because I have to learn a lot of biology/bioinformatics stuff [...]]]></description>
			<content:encoded><![CDATA[<p>Classes have started again for the spring semester and I&#8217;m off my co-op, so I&#8217;m back in full-time classes. I do have to pay the bills, though, so I&#8217;m working for one of my professors. He called it &#8220;undergraduate research,&#8221; and it is kinda that because I have to learn a lot of biology/bioinformatics stuff that I didn&#8217;t know, but it&#8217;s mostly web development. There&#8217;s this Perl web interface for interacting with a MySQL database. Now, what&#8217;s Rails good for? Why, providing a web interface for interacting with a database! I therefore plan to rewrite the Perl stuff (which is pretty hairy, especially since the original author 1) was learning Perl as he wrote it and 2) the specs were being changed as he wrote it) using Rails. I&#8217;m currently only putting in 6 hours per week but I think I want to increase that on a per-weekly basis, when I can. I&#8217;m itching to do more Rails coding and the extra money would be nice, too.</p>
<p>As part of this research, on Thursday I had to attend a bioinformatics lecture about the <a href="http://rgd.mcw.edu/">Rat Genome Database</a>. I didn&#8217;t understand 99% of it because I don&#8217;t know what QTL&#8217;s or EST&#8217;s are, but then the guy said he built one of the tools he was demoing with Ruby on Rails, which tickled me. He said he did it in about six weeks and the hardest part was getting it deployed, which I can understand.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.3till7.net/2007/02/09/back-in-rails-work/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</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 17:38:00 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[Programming]]></category>
		<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 "") {</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>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
