<?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>Aaron Toponce &#187; Perl</title> <atom:link href="http://pthree.org/category/perl/feed/" rel="self" type="application/rss+xml" /><link>http://pthree.org</link> <description>Linux.  GNU.  Freedom.</description> <lastBuildDate>Wed, 01 Sep 2010 22:04:20 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.1-alpha</generator> <item><title>Irssi GUI Notify</title><link>http://pthree.org/2007/03/21/irssi-gui-notify/</link> <comments>http://pthree.org/2007/03/21/irssi-gui-notify/#comments</comments> <pubDate>Thu, 22 Mar 2007 02:45:13 +0000</pubDate> <dc:creator>Aaron</dc:creator> <category><![CDATA[Perl]]></category> <category><![CDATA[Scripting]]></category><guid
isPermaLink="false">http://www.pthree.org/2007/03/21/irssi-gui-notify/</guid> <description><![CDATA[I am currently connected to two Irssi instances coupled with screen. One instance at home, for all my personal IRC needs, and the other at a corporate LAN for secure inter-office IRC messaging. It works great, except when someone tries to get a hold of you (a highlight). I haven&#8217;t found any good way for [...]]]></description> <content:encoded><![CDATA[<p>I am currently connected to two Irssi instances coupled with screen.  One instance at home, for all my personal IRC needs, and the other at a corporate LAN for secure inter-office IRC messaging.  It works great, except when someone tries to get a hold of you (a highlight).  I haven&#8217;t found any good way for Irssi to notify you when you have been highlighted in a channel.  For the past couple years, it hasn&#8217;t been bothering me.  Then, I found a pretty slick notification system for Irssi, and now I&#8217;m hooked. Here is a how-to for getting a GUI notification on your desktop (Gnome or KDE) when someone highlights you in a channel.</p><p>For this tutorial, it assumes that Irssi is running on a box separate from your current local machine that you have SSH access to.  For example, at work, we have an inter-office server that is running an IRC server.  I just SSH into that server from my workstation, fire up screen then Irssi, and connect to it.  Irssi is running remotely from my desktop.  This is also the case for my personal Irssi session.  So, in other words, Irssi is running under screen remotely, and you connect to that session from any other computer via SSH.</p><p>First, there is <a
href="http://thorstenl.blogspot.com/2007/01/thls-irssi-notification-script.html">fnotify.pl</a>, a Perl script for Irssi to save the highlights you get in a channel to a file.  Save this script to your ~/.irssi/scripts/ directory:</p><pre>aaron@achilles:~$ mv fnotify.pl ~/.irssi/scripts</pre><p>Now, if you want the script to run automatically when you launch Irssi, then create a directory called &#8216;autorun&#8217; in the ~/.irssi/scripts/ directory, and create a symbolic link to fnotify.pl so Irssi starts it up automatically when loaded:</p><pre>aaron@achilles:~$ cd ~/.irssi/scripts/autorun &#038;&#038; ln -s ../fnotify.pl .</pre><p>Once copied in, either start your Irssi session, or if it is already running, then execute the script in Irssi itself:</p><pre>/RUN fnotify.pl</pre><p>When running, it creates a file called &#8216;fnotify&#8217; in the ~/.irssi/ directory.  It is just a plain text file containing all the times you have been highlighted in a channel, one highlight per line.</p><p>We need to get the highlights in the appropriate channel to our desktop, so we can visually see them when we are not looking at Irssi itself. You will need notify-send to notify you when someone says your name in a channel.  If not installed, install libnotify-bin (Ubuntu/Debian syntax below):</p><pre>aaron@hercules:~$ sudo aptitude install libnotify-bin</pre><p>Now, we just need to write a shell script to send us the GUI notifications.  This can be done with a <a
href="http://thorstenl.blogspot.com/2007/01/thls-irssi-notification-script.html">simple Bash script</a> (yes, from the same page we got the Perl script for Irssi).  Save it anywhere on your local box (not the box that is running the Irssi instance; like your workstation, for example) and execute it (here, I saved it as &#8216;irssi_notify.sh&#8217;).</p><p>In the script above, you need to replace &#8216;remote.system.somewhere&#8217; with your server that you are connecting to.  The script makes an SSH connection to the server that you specified, and parses through ~/.irssi/fnotify one line at a time.  Each line gets its own notification.  That line is then removed from the file, so it doesn&#8217;t continuously grow as you continue to get highlighted in channels.</p><p>There you go.  That&#8217;s it!  Pretty easy, but a little hackish.  But that&#8217;s okay.  Isn&#8217;t that what computers are all about?  To automate human tasks?  Besides, what fun would it be, if it weren&#8217;t hackish?  At any rate, a screenshot of the notification results is shown below (you can see the notifications in the bottom-right of the screenshot).  But first, a couple caveats:</p><p>1. If the screensaver kicks in, and you are highlighted in a channel, you will not receive a GUI notification.  This is default behavior with libnotify-bin.<br
/> 2. By default, Irssi only highlights the nick that mentioned your nick if your nick is first on the line.  Otherwise, it is not the case.  This can be fixed highlighting the nick that mentions your nick anywhere in the text.  Do the following in Irssi:</p><pre>/hilight -nick (your_nick)</pre><p>Thanks to <a
href="http://fedora-tutorials.com/2007/03/20/fedora-people-rule/">Clint</a> for bringing this to my attention!  Click for a larger screenshot.</p><p><a
href='http://www.pthree.org/wp-content/uploads/2007/03/irssi_notify.png' border='0'><img
src='http://www.pthree.org/wp-content/uploads/2007/03/irssi_notify.thumbnail.png' alt='irssi_notify.png' /></a></p> ]]></content:encoded> <wfw:commentRss>http://pthree.org/2007/03/21/irssi-gui-notify/feed/</wfw:commentRss> <slash:comments>18</slash:comments> </item> <item><title>Poll: First Programming Language?</title><link>http://pthree.org/2007/03/13/poll-first-programming-language/</link> <comments>http://pthree.org/2007/03/13/poll-first-programming-language/#comments</comments> <pubDate>Tue, 13 Mar 2007 16:47:19 +0000</pubDate> <dc:creator>Aaron</dc:creator> <category><![CDATA[PHP]]></category> <category><![CDATA[Perl]]></category> <category><![CDATA[Python]]></category> <category><![CDATA[Ruby]]></category> <category><![CDATA[Scripting]]></category><guid
isPermaLink="false">http://www.pthree.org/2007/03/13/poll-first-programming-language/</guid> <description><![CDATA[My coworker asked me this question, and began asking a few others in a couple IRC channels. So, I thought I&#8217;d extend it to my blog, and the planets that I syndicate. I added as many choices as I could hoping to see a wide array of votes. I added a few newer languages for [...]]]></description> <content:encoded><![CDATA[<p>My coworker asked me this question, and began asking a few others in a couple IRC channels.  So, I thought I&#8217;d extend it to my blog, and the planets that I syndicate.  I added as many choices as I could hoping to see a wide array of votes.  I added a few newer languages for the younger audience.</p><p>For me, my first language that I sat down and learned in a formal setting was Java.  However, I had TI, Casio, and HP calculators, as well as an Atari 800 that I would fiddle with, and program.  So, Basic was really the first language that I toyed with.  I just never sat down, and took the time to &#8220;learn&#8221; it.</p><p>So, for all the programmers, coders, script kiddies and developers out there, what is the 1st programming language that you learned?  If applicable, leave a comment specifying the system that you learned the language on.</p><div><div
class='democracy'> <strong
class="poll-question">What was the 1st programming language that you learned?</strong><div
class='dem-results'><form
action='http://pthree.org/wp-content/plugins/democracy/democracy.php' onsubmit='return dem_Vote(this)'><ul><li> <input
type='radio' id='dem-choice-19' value='19' name='dem_poll_4' /> <label
for='dem-choice-19'>Basic</label></li><li> <input
type='radio' id='dem-choice-20' value='20' name='dem_poll_4' /> <label
for='dem-choice-20'>Pascal</label></li><li> <input
type='radio' id='dem-choice-21' value='21' name='dem_poll_4' /> <label
for='dem-choice-21'>C</label></li><li> <input
type='radio' id='dem-choice-22' value='22' name='dem_poll_4' /> <label
for='dem-choice-22'>Perl</label></li><li> <input
type='radio' id='dem-choice-23' value='23' name='dem_poll_4' /> <label
for='dem-choice-23'>Lisp</label></li><li> <input
type='radio' id='dem-choice-24' value='24' name='dem_poll_4' /> <label
for='dem-choice-24'>Fortran</label></li><li> <input
type='radio' id='dem-choice-25' value='25' name='dem_poll_4' /> <label
for='dem-choice-25'>Assembly</label></li><li> <input
type='radio' id='dem-choice-26' value='26' name='dem_poll_4' /> <label
for='dem-choice-26'>PHP</label></li><li> <input
type='radio' id='dem-choice-27' value='27' name='dem_poll_4' /> <label
for='dem-choice-27'>ASP / ASP.NET</label></li><li> <input
type='radio' id='dem-choice-28' value='28' name='dem_poll_4' /> <label
for='dem-choice-28'>C++</label></li><li> <input
type='radio' id='dem-choice-29' value='29' name='dem_poll_4' /> <label
for='dem-choice-29'>Python</label></li><li> <input
type='radio' id='dem-choice-30' value='30' name='dem_poll_4' /> <label
for='dem-choice-30'>Java</label></li><li> <input
type='radio' id='dem-choice-31' value='31' name='dem_poll_4' /> <label
for='dem-choice-31'>sh / csh / bash</label></li><li> <input
type='radio' id='dem-choice-32' value='32' name='dem_poll_4' /> <label
for='dem-choice-32'>Ruby</label></li><li> <input
type='radio' id='dem-choice-33' value='33' name='dem_poll_4' /> <label
for='dem-choice-33'>Other</label></li></ul> <input
type='hidden' name='dem_poll_id' value='4' /> <input
type='hidden' name='dem_action' value='vote' /> <input
type='submit' class='dem-vote-button' value='Vote' /> <a
href='/category/perl/feed/?dem_action=view&amp;dem_poll_id=4' onclick='return dem_getVotes("http://pthree.org/wp-content/plugins/democracy/democracy.php?dem_action=view&amp;dem_poll_id=4", this)' rel='nofollow' class='dem-vote-link'>View Results</a></form></div></div></div> ]]></content:encoded> <wfw:commentRss>http://pthree.org/2007/03/13/poll-first-programming-language/feed/</wfw:commentRss> <slash:comments>46</slash:comments> </item> <item><title>Simple Recursion in Perl</title><link>http://pthree.org/2007/01/18/simple-recursion-in-perl/</link> <comments>http://pthree.org/2007/01/18/simple-recursion-in-perl/#comments</comments> <pubDate>Thu, 18 Jan 2007 17:15:13 +0000</pubDate> <dc:creator>Aaron</dc:creator> <category><![CDATA[Perl]]></category><guid
isPermaLink="false">http://www.pthree.org/2007/01/18/simple-recursion-in-perl/</guid> <description><![CDATA[I&#8217;m going to embarrass myself today, and post some hack-ish Perl code using recursion. Actually, because the code is only 35 lines, I think it turned out actually fairly well, but as I am a Perl n00b, I am sure that the experts out there will disagree with the quality of the code. First and [...]]]></description> <content:encoded><![CDATA[<p>I&#8217;m going to embarrass myself today, and post some hack-ish Perl code using recursion.  Actually, because the code is only 35 lines, I think it turned out actually fairly well, but as I am a Perl n00b, I am sure that the experts out there will disagree with the quality of the code.</p><p>First and foremost, I have a global variable used as a counter.  I know that this is a BIG NO-NO, but, because the code is only 35 lines in length, I&#8217;m not too worried.  I do recognize, though, that passing the counter by reference through the recursive function PrintFiles() would probably be the better way to handle that, but then, that&#8217;s just making things a bit more difficult than I care at this point.</p><p>What does the program do?  It should be fairly obvious: it runs through a root directory structure, looking for OGG Vorbis files, counting them, and printing the results to another text file for inventory.  Basic, gets the job done, and without a lot of fanfare.  The code should be self-evident, but I&#8217;m anal about commenting code, so redundant comments are placed throughout.  The program was just an exercise for me to:</p><ol><li>Increase my ability to do simple recursion.</li><li>Learn recursion using Perl.</li><li>Create an inventory of my music.</li></ol><p>Anyway, here&#8217;s the code:</p><div
class="codecolorer-container perl twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table
cellspacing="0" cellpadding="0"><tbody><tr><td
style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br
/>2<br
/>3<br
/>4<br
/>5<br
/>6<br
/>7<br
/>8<br
/>9<br
/>10<br
/>11<br
/>12<br
/>13<br
/>14<br
/>15<br
/>16<br
/>17<br
/>18<br
/>19<br
/>20<br
/>21<br
/>22<br
/>23<br
/>24<br
/>25<br
/>26<br
/>27<br
/>28<br
/>29<br
/>30<br
/>31<br
/>32<br
/>33<br
/>34<br
/>35<br
/></div></td><td><div
class="perl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span
style="color: #666666; font-style: italic;">#!/usr/bin/perl -w</span><br
/> <br
/> <span
style="color: #000066;">open</span><span
style="color: #009900;">&#40;</span>OUT<span
style="color: #339933;">,</span> <span
style="color: #ff0000;">&quot;&gt;oggfiles.txt&quot;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span> <span
style="color: #666666; font-style: italic;"># Create the file to read to</span><br
/> <span
style="color: #0000ff;">$counter</span> <span
style="color: #339933;">=</span> <span
style="color: #cc66cc;">0</span><span
style="color: #339933;">;</span> &nbsp; <span
style="color: #666666; font-style: italic;"># Global variable (no-no)!! :)</span><br
/> <br
/> <span
style="color: #000000; font-weight: bold;">sub</span> PrintFiles&nbsp; <span
style="color: #666666; font-style: italic;"># Recursive function for printing dir contents</span><br
/> <span
style="color: #009900;">&#123;</span><br
/> &nbsp; &nbsp; <span
style="color: #b1b100;">my</span> <span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$indent</span><span
style="color: #009900;">&#41;</span> <span
style="color: #339933;">=</span> <span
style="color: #0000ff;">@_</span><span
style="color: #339933;">;</span>&nbsp; <span
style="color: #666666; font-style: italic;"># Keep track of indentation</span><br
/> &nbsp; &nbsp; <span
style="color: #000066;">opendir</span><span
style="color: #009900;">&#40;</span>MD<span
style="color: #339933;">,</span> <span
style="color: #ff0000;">&quot;./&quot;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span>&nbsp; <span
style="color: #666666; font-style: italic;"># Start looking through local directory</span><br
/> &nbsp; &nbsp; <br
/> &nbsp; &nbsp; <span
style="color: #b1b100;">foreach</span> <span
style="color: #b1b100;">my</span> <span
style="color: #0000ff;">$file</span> <span
style="color: #009900;">&#40;</span><span
style="color: #000066;">sort</span> <span
style="color: #000066;">readdir</span> MD<span
style="color: #009900;">&#41;</span>&nbsp; <span
style="color: #666666; font-style: italic;"># Start a loop going through each dir sorted</span><br
/> &nbsp; &nbsp; <span
style="color: #009900;">&#123;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #b1b100;">unless</span><span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$file</span> <span
style="color: #339933;">=~</span> <span
style="color: #009966; font-style: italic;">m/^\./</span> <span
style="color: #339933;">||</span> <span
style="color: #0000ff;">$file</span> <span
style="color: #339933;">=~</span> <span
style="color: #009966; font-style: italic;">m/^ogg/</span><span
style="color: #009900;">&#41;</span> <span
style="color: #666666; font-style: italic;"># Prevent an infinite loop, don't worry about hidden (.*), oggdir.pl and oggfiles.txt files</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #009900;">&#123;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #0000ff;">$counter</span><span
style="color: #339933;">++</span> <span
style="color: #b1b100;">if</span> <span
style="color: #0000ff;">$file</span> <span
style="color: #339933;">=~</span> <span
style="color: #009966; font-style: italic;">m/\.ogg$/</span><span
style="color: #339933;">;</span> &nbsp; <span
style="color: #666666; font-style: italic;"># Keep a counter for every ogg file</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br
/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #000066;">print</span> OUT <span
style="color: #0000ff;">$indent</span> <span
style="color: #339933;">.</span> <span
style="color: #0000ff;">$file</span> <span
style="color: #339933;">.</span> <span
style="color: #ff0000;">&quot;<span
style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span
style="color: #339933;">;</span> &nbsp; <span
style="color: #666666; font-style: italic;"># Print dir contents to a file</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br
/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #b1b100;">if</span> <span
style="color: #009900;">&#40;</span><span
style="color: #339933;">-</span>d <span
style="color: #0000ff;">$file</span><span
style="color: #009900;">&#41;</span> &nbsp; <span
style="color: #666666; font-style: italic;"># If a directory</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #009900;">&#123;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #000066;">chdir</span> <span
style="color: #0000ff;">$file</span><span
style="color: #339933;">;</span>&nbsp; &nbsp; <span
style="color: #666666; font-style: italic;"># Change to the directory</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PrintFiles<span
style="color: #009900;">&#40;</span><span
style="color: #ff0000;">&quot;$indent &nbsp;&quot;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span>&nbsp; &nbsp; <span
style="color: #666666; font-style: italic;"># Call the recursive function again, incrementing the ident</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #000066;">chdir</span> <span
style="color: #ff0000;">&quot;../&quot;</span><span
style="color: #339933;">;</span>&nbsp; &nbsp; <span
style="color: #666666; font-style: italic;"># Change back</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #009900;">&#125;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #009900;">&#125;</span><br
/> &nbsp; &nbsp; <span
style="color: #009900;">&#125;</span><br
/> &nbsp; &nbsp; <br
/> &nbsp; &nbsp; <span
style="color: #000066;">closedir</span><span
style="color: #009900;">&#40;</span>MD<span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span> &nbsp; <span
style="color: #666666; font-style: italic;"># Close the dir</span><br
/> <span
style="color: #009900;">&#125;</span><br
/> <br
/> PrintFiles<span
style="color: #009900;">&#40;</span><span
style="color: #ff0000;">&quot;&quot;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span> &nbsp; &nbsp; <span
style="color: #666666; font-style: italic;"># First call of the recursive function, with no spaces for indentation</span><br
/> <br
/> <span
style="color: #000066;">print</span> OUT <span
style="color: #ff0000;">&quot;<span
style="color: #000099; font-weight: bold;">\n</span>Current number of music files: &quot;</span> <span
style="color: #339933;">.</span> <span
style="color: #0000ff;">$counter</span> <span
style="color: #339933;">.</span> <span
style="color: #ff0000;">&quot;<span
style="color: #000099; font-weight: bold;">\n</span><span
style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span
style="color: #339933;">;</span><br
/> <br
/> <span
style="color: #000066;">close</span><span
style="color: #009900;">&#40;</span>OUT<span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span> <span
style="color: #666666; font-style: italic;"># Close file written to</span></div></td></tr></tbody></table></div> ]]></content:encoded> <wfw:commentRss>http://pthree.org/2007/01/18/simple-recursion-in-perl/feed/</wfw:commentRss> <slash:comments>6</slash:comments> </item> <item><title>Perl Versus Ruby on CSV</title><link>http://pthree.org/2006/12/29/perl-versus-ruby-on-csv/</link> <comments>http://pthree.org/2006/12/29/perl-versus-ruby-on-csv/#comments</comments> <pubDate>Sat, 30 Dec 2006 02:15:13 +0000</pubDate> <dc:creator>Aaron</dc:creator> <category><![CDATA[Perl]]></category> <category><![CDATA[Ruby]]></category> <category><![CDATA[Scripting]]></category><guid
isPermaLink="false">http://www.pthree.org/2006/12/29/perl-versus-ruby-on-csv/</guid> <description><![CDATA[Ok. I had a little project at work, at which point, I turned to Perl to accomplish the task. The project was simple enough: take a comma-separated file, and look at a few fields to see what data is contained. Based on that data, create a &#8220;weight&#8221;, and assign the weight to the record at [...]]]></description> <content:encoded><![CDATA[<p>Ok.  I had a little project at work, at which point, I turned to Perl to accomplish the task.  The project was simple enough: take a comma-separated file, and look at a few fields to see what data is contained.  Based on that data, create a &#8220;weight&#8221;, and assign the weight to the record at the end of the line.</p><p>The Perl code I used to accomplish the task is as follows (please take note, that WordPress loves to parse tags, even if contained within &lt;code&gt; tags.  WordPress also likes to lowercase the tag, so in Perl, file handles will be in lowercase):</p><div
class="codecolorer-container perl twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table
cellspacing="0" cellpadding="0"><tbody><tr><td
style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br
/>2<br
/>3<br
/>4<br
/>5<br
/>6<br
/>7<br
/>8<br
/>9<br
/>10<br
/>11<br
/>12<br
/>13<br
/>14<br
/>15<br
/>16<br
/>17<br
/>18<br
/>19<br
/>20<br
/>21<br
/>22<br
/>23<br
/>24<br
/>25<br
/>26<br
/>27<br
/>28<br
/>29<br
/>30<br
/>31<br
/>32<br
/>33<br
/>34<br
/>35<br
/>36<br
/>37<br
/>38<br
/>39<br
/>40<br
/>41<br
/>42<br
/>43<br
/>44<br
/>45<br
/>46<br
/>47<br
/>48<br
/>49<br
/>50<br
/></div></td><td><div
class="perl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span
style="color: #666666; font-style: italic;">#!/usr/bin/perl -w</span><br
/> <br
/> <span
style="color: #000066;">open</span><span
style="color: #009900;">&#40;</span>IN<span
style="color: #339933;">,</span> <span
style="color: #ff0000;">&quot;UNIVERSE.csv&quot;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> <span
style="color: #000066;">open</span><span
style="color: #009900;">&#40;</span>OUT<span
style="color: #339933;">,</span> <span
style="color: #ff0000;">&quot;&gt;UNIVERSE_WEIGHTED.csv&quot;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> <br
/> <span
style="color: #0000ff;">$counter</span> <span
style="color: #339933;">=</span> <span
style="color: #cc66cc;">0</span><span
style="color: #339933;">;</span><br
/> <br
/> <span
style="color: #b1b100;">while</span><span
style="color: #009900;">&#40;</span><span
style="color: #009999;">&lt;in&gt;</span><span
style="color: #009900;">&#41;</span> <span
style="color: #666666; font-style: italic;"># &lt;/in&gt; (for Wordpress)</span><br
/> <span
style="color: #009900;">&#123;</span><br
/> &nbsp; &nbsp; <span
style="color: #0000ff;">@fields</span> <span
style="color: #339933;">=</span> <span
style="color: #000066;">split</span><span
style="color: #009900;">&#40;</span><span
style="color: #009966; font-style: italic;">/,/</span><span
style="color: #339933;">,</span><span
style="color: #0000ff;">$_</span><span
style="color: #339933;">,</span><span
style="color: #cc66cc;">183</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; <span
style="color: #0000ff;">$fields</span><span
style="color: #009900;">&#91;</span><span
style="color: #cc66cc;">182</span><span
style="color: #009900;">&#93;</span> <span
style="color: #339933;">=~</span> <span
style="color: #009966; font-style: italic;">s/\n//</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; <span
style="color: #009966; font-style: italic;">s/\n//</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; <span
style="color: #0000ff;">$counter</span><span
style="color: #339933;">++;</span><br
/> &nbsp; &nbsp; <span
style="color: #0000ff;">$weight</span> <span
style="color: #339933;">=</span> <span
style="color: #cc66cc;">0</span><span
style="color: #339933;">;</span><br
/> <br
/> &nbsp; &nbsp; <span
style="color: #b1b100;">if</span> <span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$counter</span> <span
style="color: #339933;">==</span> <span
style="color: #cc66cc;">1</span><span
style="color: #009900;">&#41;</span><br
/> &nbsp; &nbsp; <span
style="color: #009900;">&#123;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #000066;">print</span> OUT <span
style="color: #0000ff;">$_</span> <span
style="color: #339933;">.</span> <span
style="color: #ff0000;">&quot;,<span
style="color: #000099; font-weight: bold;">\&quot;</span>weight<span
style="color: #000099; font-weight: bold;">\&quot;</span><span
style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; <span
style="color: #009900;">&#125;</span><br
/> &nbsp; &nbsp; <span
style="color: #b1b100;">else</span><br
/> &nbsp; &nbsp; <span
style="color: #009900;">&#123;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #0000ff;">$vtr_ppp00</span> <span
style="color: #339933;">=</span> <span
style="color: #0000ff;">$fields</span><span
style="color: #009900;">&#91;</span><span
style="color: #cc66cc;">154</span><span
style="color: #009900;">&#93;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #0000ff;">$vtr_ppp04</span> <span
style="color: #339933;">=</span> <span
style="color: #0000ff;">$fields</span><span
style="color: #009900;">&#91;</span><span
style="color: #cc66cc;">155</span><span
style="color: #009900;">&#93;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #0000ff;">$vtr_pri01</span> <span
style="color: #339933;">=</span> <span
style="color: #0000ff;">$fields</span><span
style="color: #009900;">&#91;</span><span
style="color: #cc66cc;">161</span><span
style="color: #009900;">&#93;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #0000ff;">$vtr_pri03</span> <span
style="color: #339933;">=</span> <span
style="color: #0000ff;">$fields</span><span
style="color: #009900;">&#91;</span><span
style="color: #cc66cc;">163</span><span
style="color: #009900;">&#93;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #0000ff;">$vtr_pri05</span> <span
style="color: #339933;">=</span> <span
style="color: #0000ff;">$fields</span><span
style="color: #009900;">&#91;</span><span
style="color: #cc66cc;">165</span><span
style="color: #009900;">&#93;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #0000ff;">$vtr_pri99</span> <span
style="color: #339933;">=</span> <span
style="color: #0000ff;">$fields</span><span
style="color: #009900;">&#91;</span><span
style="color: #cc66cc;">182</span><span
style="color: #009900;">&#93;</span><span
style="color: #339933;">;</span><br
/> <br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #0000ff;">$weight</span> <span
style="color: #339933;">+=.</span>5 <span
style="color: #b1b100;">if</span> <span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$vtr_ppp00</span> <span
style="color: #b1b100;">eq</span> <span
style="color: #ff0000;">&quot;<span
style="color: #000099; font-weight: bold;">\&quot;</span>R<span
style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #0000ff;">$weight</span> <span
style="color: #339933;">-=</span> <span
style="color: #cc66cc;">1</span> <span
style="color: #b1b100;">if</span> <span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$vtr_ppp04</span> <span
style="color: #b1b100;">eq</span> <span
style="color: #ff0000;">&quot;<span
style="color: #000099; font-weight: bold;">\&quot;</span>D<span
style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #0000ff;">$weight</span> <span
style="color: #339933;">-=</span> <span
style="color: #cc66cc;">1</span> <span
style="color: #b1b100;">if</span> <span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$vtr_pri01</span> <span
style="color: #b1b100;">eq</span> <span
style="color: #ff0000;">&quot;<span
style="color: #000099; font-weight: bold;">\&quot;</span>D<span
style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #0000ff;">$weight</span> <span
style="color: #339933;">-=</span> <span
style="color: #cc66cc;">1</span> <span
style="color: #b1b100;">if</span> <span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$vtr_pri03</span> <span
style="color: #b1b100;">eq</span> <span
style="color: #ff0000;">&quot;<span
style="color: #000099; font-weight: bold;">\&quot;</span>D<span
style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #0000ff;">$weight</span> <span
style="color: #339933;">-=</span> <span
style="color: #cc66cc;">1</span> <span
style="color: #b1b100;">if</span> <span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$vtr_pri05</span> <span
style="color: #b1b100;">eq</span> <span
style="color: #ff0000;">&quot;<span
style="color: #000099; font-weight: bold;">\&quot;</span>D<span
style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #0000ff;">$weight</span> <span
style="color: #339933;">-=</span> <span
style="color: #cc66cc;">1</span> <span
style="color: #b1b100;">if</span> <span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$vtr_pri99</span> <span
style="color: #b1b100;">eq</span> <span
style="color: #ff0000;">&quot;<span
style="color: #000099; font-weight: bold;">\&quot;</span>D<span
style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #0000ff;">$weight</span> <span
style="color: #339933;">+=</span> <span
style="color: #cc66cc;">1</span> <span
style="color: #b1b100;">if</span> <span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$vtr_ppp04</span> <span
style="color: #b1b100;">eq</span> <span
style="color: #ff0000;">&quot;<span
style="color: #000099; font-weight: bold;">\&quot;</span>R<span
style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #0000ff;">$weight</span> <span
style="color: #339933;">+=</span> <span
style="color: #cc66cc;">1</span> <span
style="color: #b1b100;">if</span> <span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$vtr_pri01</span> <span
style="color: #b1b100;">eq</span> <span
style="color: #ff0000;">&quot;<span
style="color: #000099; font-weight: bold;">\&quot;</span>R<span
style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #0000ff;">$weight</span> <span
style="color: #339933;">+=</span> <span
style="color: #cc66cc;">1</span> <span
style="color: #b1b100;">if</span> <span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$vtr_pri03</span> <span
style="color: #b1b100;">eq</span> <span
style="color: #ff0000;">&quot;<span
style="color: #000099; font-weight: bold;">\&quot;</span>R<span
style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #0000ff;">$weight</span> <span
style="color: #339933;">+=</span> <span
style="color: #cc66cc;">1</span> <span
style="color: #b1b100;">if</span> <span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$vtr_pri05</span> <span
style="color: #b1b100;">eq</span> <span
style="color: #ff0000;">&quot;<span
style="color: #000099; font-weight: bold;">\&quot;</span>R<span
style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #0000ff;">$weight</span> <span
style="color: #339933;">+=</span> <span
style="color: #cc66cc;">1</span> <span
style="color: #b1b100;">if</span> <span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$vtr_pri99</span> <span
style="color: #b1b100;">eq</span> <span
style="color: #ff0000;">&quot;<span
style="color: #000099; font-weight: bold;">\&quot;</span>R<span
style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; <br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #000066;">print</span> OUT <span
style="color: #0000ff;">$_</span> <span
style="color: #339933;">.</span> <span
style="color: #ff0000;">&quot;,<span
style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> <span
style="color: #339933;">.</span> <span
style="color: #0000ff;">$weight</span> <span
style="color: #339933;">.</span> <span
style="color: #ff0000;">&quot;<span
style="color: #000099; font-weight: bold;">\&quot;</span><span
style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; <span
style="color: #009900;">&#125;</span><br
/> &nbsp; &nbsp; <br
/> &nbsp; &nbsp; <span
style="color: #000066;">print</span> <span
style="color: #ff0000;">&quot;Processed: &quot;</span> <span
style="color: #339933;">.</span> <span
style="color: #0000ff;">$counter</span> <span
style="color: #339933;">.</span> <span
style="color: #ff0000;">&quot;<span
style="color: #000099; font-weight: bold;">\r</span>&quot;</span><span
style="color: #339933;">;</span><br
/> <span
style="color: #009900;">&#125;</span><br
/> <br
/> <span
style="color: #000066;">print</span> <span
style="color: #ff0000;">&quot;<span
style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span
style="color: #339933;">;</span><br
/> <br
/> <span
style="color: #000066;">close</span><span
style="color: #009900;">&#40;</span>IN<span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> <span
style="color: #000066;">close</span><span
style="color: #009900;">&#40;</span>OUT<span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span></div></td></tr></tbody></table></div><p>Just for fun, a buddy of mine mentioned to code it in Ruby, and compare results.  Seeing as though I have never coded a Ruby script in my life, I was a bit worried.  However, it wasn&#8217;t too bad.  I just had to cure my itch to put a $ in front of all my variables.  Anyway, heres the Ruby code, following as closely as possible to the Perl code:</p><div
class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table
cellspacing="0" cellpadding="0"><tbody><tr><td
style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br
/>2<br
/>3<br
/>4<br
/>5<br
/>6<br
/>7<br
/>8<br
/>9<br
/>10<br
/>11<br
/>12<br
/>13<br
/>14<br
/>15<br
/>16<br
/>17<br
/>18<br
/>19<br
/>20<br
/>21<br
/>22<br
/>23<br
/>24<br
/>25<br
/>26<br
/>27<br
/>28<br
/>29<br
/>30<br
/>31<br
/>32<br
/>33<br
/>34<br
/>35<br
/>36<br
/>37<br
/>38<br
/></div></td><td><div
class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span
style="color:#008000; font-style:italic;">#!/usr/bin/ruby</span><br
/> <br
/> counter = <span
style="color:#006666;">0</span><br
/> <br
/> outfile = <span
style="color:#CC00FF; font-weight:bold;">File</span>.<span
style="color:#CC0066; font-weight:bold;">open</span><span
style="color:#006600; font-weight:bold;">&#40;</span><span
style="color:#996600;">&quot;UNIVERSE_RUBY.csv&quot;</span>,<span
style="color:#996600;">&quot;w&quot;</span><span
style="color:#006600; font-weight:bold;">&#41;</span><br
/> <span
style="color:#CC00FF; font-weight:bold;">IO</span>.<span
style="color:#9900CC;">foreach</span><span
style="color:#006600; font-weight:bold;">&#40;</span><span
style="color:#996600;">&quot;UNIVERSE.csv&quot;</span><span
style="color:#006600; font-weight:bold;">&#41;</span> <span
style="color:#9966CC; font-weight:bold;">do</span> <span
style="color:#006600; font-weight:bold;">|</span>line<span
style="color:#006600; font-weight:bold;">|</span><br
/> &nbsp; &nbsp; counter <span
style="color:#006600; font-weight:bold;">+</span>= <span
style="color:#006666;">1</span><br
/> &nbsp; &nbsp; weight = <span
style="color:#006666;">0</span><br
/> &nbsp; &nbsp; <br
/> &nbsp; &nbsp; <span
style="color:#9966CC; font-weight:bold;">if</span> <span
style="color:#006600; font-weight:bold;">&#40;</span>counter == <span
style="color:#006666;">1</span><span
style="color:#006600; font-weight:bold;">&#41;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; outfile <span
style="color:#006600; font-weight:bold;">&lt;</span> <span
style="color:#006600; font-weight:bold;">&lt;</span> line.<span
style="color:#CC0066; font-weight:bold;">chop</span> <span
style="color:#006600; font-weight:bold;">+</span> <span
style="color:#996600;">&quot;,<span
style="color:#000099;">\&quot;</span>weight<span
style="color:#000099;">\&quot;</span><span
style="color:#000099;">\n</span>&quot;</span><br
/> &nbsp; &nbsp; <span
style="color:#9966CC; font-weight:bold;">else</span> &nbsp; &nbsp;<br
/> &nbsp; &nbsp; &nbsp; &nbsp; fields = line.<span
style="color:#CC0066; font-weight:bold;">chop</span>.<span
style="color:#CC0066; font-weight:bold;">split</span><span
style="color:#006600; font-weight:bold;">&#40;</span><span
style="color:#996600;">','</span><span
style="color:#006600; font-weight:bold;">&#41;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; vtr_ppp00 = fields<span
style="color:#006600; font-weight:bold;">&#91;</span><span
style="color:#006666;">154</span><span
style="color:#006600; font-weight:bold;">&#93;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; vtr_ppp04 = fields<span
style="color:#006600; font-weight:bold;">&#91;</span><span
style="color:#006666;">155</span><span
style="color:#006600; font-weight:bold;">&#93;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; vtr_pri01 = fields<span
style="color:#006600; font-weight:bold;">&#91;</span><span
style="color:#006666;">161</span><span
style="color:#006600; font-weight:bold;">&#93;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; vtr_pri03 = fields<span
style="color:#006600; font-weight:bold;">&#91;</span><span
style="color:#006666;">163</span><span
style="color:#006600; font-weight:bold;">&#93;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; vtr_pri05 = fields<span
style="color:#006600; font-weight:bold;">&#91;</span><span
style="color:#006666;">165</span><span
style="color:#006600; font-weight:bold;">&#93;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; vtr_pri99 = fields<span
style="color:#006600; font-weight:bold;">&#91;</span><span
style="color:#006666;">182</span><span
style="color:#006600; font-weight:bold;">&#93;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <br
/> &nbsp; &nbsp; &nbsp; &nbsp; weight <span
style="color:#006600; font-weight:bold;">+</span>= <span
style="color:#006666;">0.5</span> <span
style="color:#9966CC; font-weight:bold;">if</span> <span
style="color:#006600; font-weight:bold;">&#40;</span>vtr_ppp00 == <span
style="color:#996600;">&quot;<span
style="color:#000099;">\&quot;</span>R<span
style="color:#000099;">\&quot;</span>&quot;</span><span
style="color:#006600; font-weight:bold;">&#41;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; weight <span
style="color:#006600; font-weight:bold;">-</span>= <span
style="color:#006666;">1</span> &nbsp; <span
style="color:#9966CC; font-weight:bold;">if</span> <span
style="color:#006600; font-weight:bold;">&#40;</span>vtr_ppp04 == <span
style="color:#996600;">&quot;<span
style="color:#000099;">\&quot;</span>D<span
style="color:#000099;">\&quot;</span>&quot;</span><span
style="color:#006600; font-weight:bold;">&#41;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; weight <span
style="color:#006600; font-weight:bold;">-</span>= <span
style="color:#006666;">1</span> &nbsp; <span
style="color:#9966CC; font-weight:bold;">if</span> <span
style="color:#006600; font-weight:bold;">&#40;</span>vtr_pri01 == <span
style="color:#996600;">&quot;<span
style="color:#000099;">\&quot;</span>D<span
style="color:#000099;">\&quot;</span>&quot;</span><span
style="color:#006600; font-weight:bold;">&#41;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; weight <span
style="color:#006600; font-weight:bold;">-</span>= <span
style="color:#006666;">1</span> &nbsp; <span
style="color:#9966CC; font-weight:bold;">if</span> <span
style="color:#006600; font-weight:bold;">&#40;</span>vtr_pri03 == <span
style="color:#996600;">&quot;<span
style="color:#000099;">\&quot;</span>D<span
style="color:#000099;">\&quot;</span>&quot;</span><span
style="color:#006600; font-weight:bold;">&#41;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; weight <span
style="color:#006600; font-weight:bold;">-</span>= <span
style="color:#006666;">1</span> &nbsp; <span
style="color:#9966CC; font-weight:bold;">if</span> <span
style="color:#006600; font-weight:bold;">&#40;</span>vtr_pri05 == <span
style="color:#996600;">&quot;<span
style="color:#000099;">\&quot;</span>D<span
style="color:#000099;">\&quot;</span>&quot;</span><span
style="color:#006600; font-weight:bold;">&#41;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; weight <span
style="color:#006600; font-weight:bold;">-</span>= <span
style="color:#006666;">1</span> &nbsp; <span
style="color:#9966CC; font-weight:bold;">if</span> <span
style="color:#006600; font-weight:bold;">&#40;</span>vtr_pri99 == <span
style="color:#996600;">&quot;<span
style="color:#000099;">\&quot;</span>D<span
style="color:#000099;">\&quot;</span>&quot;</span><span
style="color:#006600; font-weight:bold;">&#41;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; weight <span
style="color:#006600; font-weight:bold;">+</span>= <span
style="color:#006666;">1</span> &nbsp; <span
style="color:#9966CC; font-weight:bold;">if</span> <span
style="color:#006600; font-weight:bold;">&#40;</span>vtr_ppp04 == <span
style="color:#996600;">&quot;<span
style="color:#000099;">\&quot;</span>R<span
style="color:#000099;">\&quot;</span>&quot;</span><span
style="color:#006600; font-weight:bold;">&#41;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; weight <span
style="color:#006600; font-weight:bold;">+</span>= <span
style="color:#006666;">1</span> &nbsp; <span
style="color:#9966CC; font-weight:bold;">if</span> <span
style="color:#006600; font-weight:bold;">&#40;</span>vtr_pri01 == <span
style="color:#996600;">&quot;<span
style="color:#000099;">\&quot;</span>R<span
style="color:#000099;">\&quot;</span>&quot;</span><span
style="color:#006600; font-weight:bold;">&#41;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; weight <span
style="color:#006600; font-weight:bold;">+</span>= <span
style="color:#006666;">1</span> &nbsp; <span
style="color:#9966CC; font-weight:bold;">if</span> <span
style="color:#006600; font-weight:bold;">&#40;</span>vtr_pri03 == <span
style="color:#996600;">&quot;<span
style="color:#000099;">\&quot;</span>R<span
style="color:#000099;">\&quot;</span>&quot;</span><span
style="color:#006600; font-weight:bold;">&#41;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; weight <span
style="color:#006600; font-weight:bold;">+</span>= <span
style="color:#006666;">1</span> &nbsp; <span
style="color:#9966CC; font-weight:bold;">if</span> <span
style="color:#006600; font-weight:bold;">&#40;</span>vtr_pri05 == <span
style="color:#996600;">&quot;<span
style="color:#000099;">\&quot;</span>R<span
style="color:#000099;">\&quot;</span>&quot;</span><span
style="color:#006600; font-weight:bold;">&#41;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; weight <span
style="color:#006600; font-weight:bold;">+</span>= <span
style="color:#006666;">1</span> &nbsp; <span
style="color:#9966CC; font-weight:bold;">if</span> <span
style="color:#006600; font-weight:bold;">&#40;</span>vtr_pri99 == <span
style="color:#996600;">&quot;<span
style="color:#000099;">\&quot;</span>R<span
style="color:#000099;">\&quot;</span>&quot;</span><span
style="color:#006600; font-weight:bold;">&#41;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <br
/> &nbsp; &nbsp; &nbsp; &nbsp; outfile <span
style="color:#006600; font-weight:bold;">&lt;</span> <span
style="color:#006600; font-weight:bold;">&lt;</span> line.<span
style="color:#CC0066; font-weight:bold;">chop</span> <span
style="color:#006600; font-weight:bold;">+</span> <span
style="color:#996600;">&quot;,<span
style="color:#000099;">\&quot;</span>&quot;</span> <span
style="color:#006600; font-weight:bold;">+</span> weight.<span
style="color:#9900CC;">to_s</span> <span
style="color:#006600; font-weight:bold;">+</span> <span
style="color:#996600;">&quot;<span
style="color:#000099;">\&quot;</span><span
style="color:#000099;">\n</span>&quot;</span><br
/> &nbsp; &nbsp; <span
style="color:#9966CC; font-weight:bold;">end</span><br
/> &nbsp; &nbsp; <span
style="color:#CC0066; font-weight:bold;">print</span> <span
style="color:#996600;">&quot;Processed: &quot;</span> <span
style="color:#006600; font-weight:bold;">+</span> counter.<span
style="color:#9900CC;">to_s</span> <span
style="color:#006600; font-weight:bold;">+</span> <span
style="color:#996600;">&quot;<span
style="color:#000099;">\r</span>&quot;</span><br
/> <span
style="color:#9966CC; font-weight:bold;">end</span><br
/> <br
/> <span
style="color:#CC0066; font-weight:bold;">print</span> <span
style="color:#996600;">&quot;<span
style="color:#000099;">\n</span>&quot;</span></div></td></tr></tbody></table></div><p>Ok.  As you can see, the code is fairly similar.  The algorithms the same.  Running the script takes a mere second or two, and the file comes out correct.  However, I was curious about execution speed, so I decided to pit one script against the other, time them, and see what happens.  Here are my results</p><pre>
aaron@hercules:~/Desktop$ time perl weight.pl
Processed: 5394

real    0m1.386s
user    0m1.304s
sys     0m0.048s
aaron@hercules:~/Desktop$ time ruby weight.rb
Processed: 5394

real    0m2.180s
user    0m1.992s
sys     0m0.124s
</pre><p>Am I reading this correctly?  Perl is almost 60% faster at execution with this code than Ruby?  I thought Ruby was supposed to have exceptional file handling.  Better than Perl, even.  However, I have also heard that the Ruby devs are more concerned about functionality than speed, which should be expected.  Still, that&#8217;s a serious speed factor.  If I was worried about speed here, Perl, in this case, would win out.</p><p>At any rate, this was a fun little exercise to stretch my scripting muscles, and to learn a bit of Ruby.  I&#8217;m curious if I can make the scripts more efficient.  If you know how, comment below, or <a
href="http://www.pthree.org/contact">contact me</a>.</code></p> ]]></content:encoded> <wfw:commentRss>http://pthree.org/2006/12/29/perl-versus-ruby-on-csv/feed/</wfw:commentRss> <slash:comments>6</slash:comments> </item> <item><title>Dvorak-QWERTY Irssi Script</title><link>http://pthree.org/2006/12/19/296/</link> <comments>http://pthree.org/2006/12/19/296/#comments</comments> <pubDate>Tue, 19 Dec 2006 22:55:06 +0000</pubDate> <dc:creator>Aaron</dc:creator> <category><![CDATA[Perl]]></category><guid
isPermaLink="false">http://www.pthree.org/2006/12/19/296/</guid> <description><![CDATA[In #utah on Freenode, there has been some active discussion lately about Dvorak vs. Qwerty. As such, ibot, a channel bot, has the ability to display text when someone enters a channel. Some of the chatters, including myself, have a join that is &#8220;encrypted&#8221;. Well, not really, per se, but rather, just Dvorak text that [...]]]></description> <content:encoded><![CDATA[<p>In #utah on Freenode, there has been some active discussion lately about Dvorak vs. Qwerty.  As such, ibot, a channel bot, has the ability to display text when someone enters a channel.  Some of the chatters, including myself, have a join that is &#8220;encrypted&#8221;.  Well, not really, per se, but rather, just Dvorak text that was typed using the QWERTY layout.  One such join is as follows:</p><pre>
&gt;&gt;&gt; vontrapp
Dr, co yd. Ekrpat jrmcbiZ</pre><p>Not exactly intuitive as to what is trying to be said.  The only way to figure it out, is set your keyboard layout to Dvorak, and type the letters as they would appear on a QWERTY keyboard.  Doing so would produce:</p><pre>
&gt;&gt;&gt; vontrapp
How is the Dvorak coming?</pre><p>As we began discussing in the channel, we thought that it would be great if we could have ibot do the decoding for us.  Well, I&#8217;m not familiar with blootbot or it&#8217;s scripting capabilities, so I wrote a script for Irssi that can convert any &#8220;Dvorak text&#8221; to QWERTY and vice versa.  The commands to run are &#8216;/dv some text here&#8217; and &#8216;/qw some text here&#8217;.  When ran, it just puts the the result in the channel in a single line, as to not flood or annoy the channel.  The script does not utilize color, but that could be added easily to help identify the difference between the input and output text.</p><p>Here is the code below (no syntax highligting.  Sorry).  Save it as &#8216;dvoark-qwerty.pl&#8217; in your ~/irssi/scripts/ directory, and run &#8220;/script load dvorak-qwerty.pl&#8221; in Irssi.</p><div
class="codecolorer-container perl twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table
cellspacing="0" cellpadding="0"><tbody><tr><td
style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br
/>2<br
/>3<br
/>4<br
/>5<br
/>6<br
/>7<br
/>8<br
/>9<br
/>10<br
/>11<br
/>12<br
/>13<br
/>14<br
/>15<br
/>16<br
/>17<br
/>18<br
/>19<br
/>20<br
/>21<br
/>22<br
/>23<br
/>24<br
/>25<br
/>26<br
/>27<br
/>28<br
/>29<br
/>30<br
/>31<br
/>32<br
/>33<br
/>34<br
/>35<br
/>36<br
/>37<br
/>38<br
/>39<br
/>40<br
/>41<br
/>42<br
/>43<br
/>44<br
/>45<br
/>46<br
/>47<br
/>48<br
/>49<br
/>50<br
/>51<br
/>52<br
/>53<br
/>54<br
/>55<br
/>56<br
/>57<br
/>58<br
/>59<br
/>60<br
/>61<br
/>62<br
/>63<br
/>64<br
/>65<br
/>66<br
/>67<br
/>68<br
/>69<br
/>70<br
/>71<br
/>72<br
/>73<br
/>74<br
/>75<br
/>76<br
/>77<br
/>78<br
/></div></td><td><div
class="perl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span
style="color: #666666; font-style: italic;"># dvorak-qwerty.pl</span><br
/> <span
style="color: #666666; font-style: italic;"># Aaron Toponce (aaron .toponce@gmail.com)</span><br
/> <span
style="color: #666666; font-style: italic;"># Decodes dvorak to qwerty and qwerty to dvorak</span><br
/> <span
style="color: #666666; font-style: italic;">#</span><br
/> <span
style="color: #666666; font-style: italic;"># qwerty layout (from left to right, top to bottom): _+QWERTYUIOP{}ASDFGHJKL:\&quot;ZXCVBNM&lt;&gt;?-=qwertyuiop[]asdfghjkl;'zxcvbnm,./</span><br
/> <span
style="color: #666666; font-style: italic;"># dvorak layout &nbsp;(from left to right, top to bottom): {}\&quot;&lt;&gt;PYFGCRL?+AOEUIDHTNS_:QJKXBMWVZ[]',.pyfgcrl/=aoeuidhtns-;qjkxbmwvz</span><br
/> <br
/> <span
style="color: #000000; font-weight: bold;">use</span> Irssi<span
style="color: #339933;">;</span><br
/> <span
style="color: #000000; font-weight: bold;">use</span> strict<span
style="color: #339933;">;</span><br
/> <span
style="color: #000000; font-weight: bold;">use</span> vars <span
style="color: #000066;">qw</span><span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$VERSION</span> <span
style="color: #0000ff;">%IRSSI</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> <br
/> <span
style="color: #0000ff;">$VERSION</span> <span
style="color: #339933;">=</span> <span
style="color: #ff0000;">&quot;0.1&quot;</span><span
style="color: #339933;">;</span><br
/> <span
style="color: #0000ff;">%IRSSI</span> <span
style="color: #339933;">=</span> <span
style="color: #009900;">&#40;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; authors &nbsp; &nbsp; <span
style="color: #339933;">=&gt;</span>&nbsp; <span
style="color: #ff0000;">&quot;Aaron Toponce&quot;</span><span
style="color: #339933;">,</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; contact &nbsp; &nbsp; <span
style="color: #339933;">=&gt;</span>&nbsp; <span
style="color: #ff0000;">&quot;aaron.toponce<span
style="color: #000099; font-weight: bold;">\@</span>gmail.com&quot;</span><span
style="color: #339933;">,</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; name&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #339933;">=&gt;</span>&nbsp; <span
style="color: #ff0000;">&quot;dvorak-qwerty&quot;</span><span
style="color: #339933;">,</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; decscription&nbsp; &nbsp; <span
style="color: #339933;">=&gt;</span>&nbsp; <span
style="color: #ff0000;">&quot;Decodes dvorak-to-qwerty and reverse&quot;</span><span
style="color: #339933;">,</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; license &nbsp; &nbsp; <span
style="color: #339933;">=&gt;</span>&nbsp; <span
style="color: #ff0000;">&quot;GPLv2&quot;</span><span
style="color: #339933;">,</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; changed &nbsp; &nbsp; <span
style="color: #339933;">=&gt;</span>&nbsp; <span
style="color: #ff0000;">&quot;$VERSION&quot;</span><span
style="color: #339933;">,</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; commands&nbsp; &nbsp; <span
style="color: #339933;">=&gt;</span>&nbsp; <span
style="color: #ff0000;">&quot;dvorak qwerty&quot;</span><br
/> <span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> <br
/> <span
style="color: #000000; font-weight: bold;">sub</span> qwerty2dvorak<span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$)</span><br
/> <span
style="color: #009900;">&#123;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #b1b100;">my</span> <span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$text</span><span
style="color: #009900;">&#41;</span> <span
style="color: #339933;">=</span> <span
style="color: #0000ff;">@_</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #0000ff;">$text</span> <span
style="color: #339933;">=~</span> <span
style="color: #009966; font-style: italic;">y/\_\+QWERTYUIOP\{\}ASDFGHJKL\:\&quot;ZXCVBNM\&lt;\&gt;\?\-\=qwertyuiop\[\]asdfghjkl\;\'zxcvbnm\,\.\//\{\}\&quot;\&lt;\&gt;PYFGCRL\?\+AOEUIDHTNS\_\:QJKXBMWVZ\[\]\'\,\.pyfgcrl\/\=aoeuidhtns\-\;qjkxbmwvz/</span><span
style="color: #339933;">;</span> <span
style="color: #666666; font-style: italic;"># &quot;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #000066;">return</span> <span
style="color: #ff0000;">&quot;'@_' to dvorak: &quot;</span> <span
style="color: #339933;">.</span> <span
style="color: #0000ff;">$text</span><span
style="color: #339933;">;</span><br
/> <span
style="color: #009900;">&#125;</span><br
/> <br
/> <span
style="color: #000000; font-weight: bold;">sub</span> dvorak2qwerty<span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$)</span><br
/> <span
style="color: #009900;">&#123;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #b1b100;">my</span> <span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$text</span><span
style="color: #009900;">&#41;</span> <span
style="color: #339933;">=</span> <span
style="color: #0000ff;">@_</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #0000ff;">$text</span> <span
style="color: #339933;">=~</span> <span
style="color: #009966; font-style: italic;">y/\{\}\&quot;\&lt;\&gt;PYFGCRL\?\+AOEUIDHTNS\_\:QJKXBMWVZ\[\]\'\,\.pyfgcrl\/\=aoeuidhtns\-\;qjkxbmwvz/\_\+QWERTYUIOP\{\}ASDFGHJKL\:\&quot;ZXCVBNM\&lt;\&gt;\?\-\=qwertyuiop\[\]asdfghjkl\;\'zxcvbnm\,\.\//</span><span
style="color: #339933;">;</span> <span
style="color: #666666; font-style: italic;"># &quot;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #000066;">return</span> <span
style="color: #ff0000;">&quot;'@_' to qwerty: &quot;</span> <span
style="color: #339933;">.</span> <span
style="color: #0000ff;">$text</span><span
style="color: #339933;">;</span><br
/> <span
style="color: #009900;">&#125;</span><br
/> <br
/> <span
style="color: #000000; font-weight: bold;">sub</span> dvorak_decode<span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$$</span><span
style="color: #0000ff;">$)</span><br
/> <span
style="color: #009900;">&#123;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #b1b100;">my</span> <span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$server</span><span
style="color: #339933;">,</span> <span
style="color: #0000ff;">$target</span><span
style="color: #339933;">,</span> <span
style="color: #0000ff;">$text</span><span
style="color: #009900;">&#41;</span> <span
style="color: #339933;">=</span> <span
style="color: #0000ff;">@_</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #000066;">return</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #b1b100;">my</span> <span
style="color: #0000ff;">$witem</span> <span
style="color: #339933;">=</span> <span
style="color: #0000ff;">$server</span><span
style="color: #339933;">-&gt;</span><span
style="color: #006600;">window_item_find</span><span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$target</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #000066;">return</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #0000ff;">$witem</span><span
style="color: #339933;">-&gt;</span><span
style="color: #006600;">print</span><span
style="color: #009900;">&#40;</span>dvorak2qwerty<span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$1</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">,</span> MSGLEVEL_CLIENTCRAP<span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> <span
style="color: #009900;">&#125;</span><br
/> <br
/> <span
style="color: #000000; font-weight: bold;">sub</span> cmd_dvorak<span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$$</span><span
style="color: #0000ff;">$)</span><br
/> <span
style="color: #009900;">&#123;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #b1b100;">my</span> <span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$arg</span><span
style="color: #339933;">,</span> <span
style="color: #0000ff;">$server</span><span
style="color: #339933;">,</span> <span
style="color: #0000ff;">$witem</span><span
style="color: #009900;">&#41;</span> <span
style="color: #339933;">=</span> <span
style="color: #0000ff;">@_</span><span
style="color: #339933;">;</span><br
/> <br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #b1b100;">if</span><span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$witem</span> <span
style="color: #339933;">&amp;&amp;</span> <span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$witem</span><span
style="color: #339933;">-&gt;</span><span
style="color: #009900;">&#123;</span>type<span
style="color: #009900;">&#125;</span> <span
style="color: #b1b100;">eq</span> <span
style="color: #ff0000;">'CHANNEL'</span> <span
style="color: #339933;">||</span> <span
style="color: #0000ff;">$witem</span><span
style="color: #339933;">-&gt;</span><span
style="color: #009900;">&#123;</span>type<span
style="color: #009900;">&#125;</span> <span
style="color: #b1b100;">eq</span> <span
style="color: #ff0000;">'QUERY'</span><span
style="color: #009900;">&#41;</span><span
style="color: #009900;">&#41;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #009900;">&#123;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #0000ff;">$witem</span><span
style="color: #339933;">-&gt;</span><span
style="color: #006600;">command</span><span
style="color: #009900;">&#40;</span><span
style="color: #ff0000;">'MSG '</span> <span
style="color: #339933;">.</span> <span
style="color: #0000ff;">$witem</span><span
style="color: #339933;">-&gt;</span><span
style="color: #009900;">&#123;</span>name<span
style="color: #009900;">&#125;</span> <span
style="color: #339933;">.</span> <span
style="color: #ff0000;">' '</span> <span
style="color: #339933;">.</span> qwerty2dvorak<span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$arg</span><span
style="color: #009900;">&#41;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #009900;">&#125;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #b1b100;">else</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #009900;">&#123;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #000066;">print</span> qwerty2dvorak<span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$arg</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #009900;">&#125;</span><br
/> <span
style="color: #009900;">&#125;</span><br
/> <br
/> <span
style="color: #000000; font-weight: bold;">sub</span> cmd_qwerty<span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$$</span><span
style="color: #0000ff;">$)</span><br
/> <span
style="color: #009900;">&#123;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #b1b100;">my</span> <span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$arg</span><span
style="color: #339933;">,</span> <span
style="color: #0000ff;">$server</span><span
style="color: #339933;">,</span> <span
style="color: #0000ff;">$witem</span><span
style="color: #009900;">&#41;</span> <span
style="color: #339933;">=</span> <span
style="color: #0000ff;">@_</span><span
style="color: #339933;">;</span><br
/> <br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #b1b100;">if</span><span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$witem</span> <span
style="color: #339933;">&amp;&amp;</span> <span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$witem</span><span
style="color: #339933;">-&gt;</span><span
style="color: #009900;">&#123;</span>type<span
style="color: #009900;">&#125;</span> <span
style="color: #b1b100;">eq</span> <span
style="color: #ff0000;">'CHANNEL'</span> <span
style="color: #339933;">||</span> <span
style="color: #0000ff;">$witem</span><span
style="color: #339933;">-&gt;</span><span
style="color: #009900;">&#123;</span>type<span
style="color: #009900;">&#125;</span> <span
style="color: #b1b100;">eq</span> <span
style="color: #ff0000;">'QUERY'</span><span
style="color: #009900;">&#41;</span><span
style="color: #009900;">&#41;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #009900;">&#123;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #0000ff;">$witem</span><span
style="color: #339933;">-&gt;</span><span
style="color: #006600;">command</span><span
style="color: #009900;">&#40;</span><span
style="color: #ff0000;">'MSG '</span> <span
style="color: #339933;">.</span> <span
style="color: #0000ff;">$witem</span><span
style="color: #339933;">-&gt;</span><span
style="color: #009900;">&#123;</span>name<span
style="color: #009900;">&#125;</span> <span
style="color: #339933;">.</span> <span
style="color: #ff0000;">' '</span> <span
style="color: #339933;">.</span> dvorak2qwerty<span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$arg</span><span
style="color: #009900;">&#41;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #009900;">&#125;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #b1b100;">else</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #009900;">&#123;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #000066;">print</span> dvorak2qwerty<span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$arg</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #009900;">&#125;</span><br
/> <span
style="color: #009900;">&#125;</span><br
/> <br
/> Irssi<span
style="color: #339933;">::</span><span
style="color: #006600;">command_bind</span><span
style="color: #009900;">&#40;</span><span
style="color: #ff0000;">'dv'</span><span
style="color: #339933;">,</span><span
style="color: #0000ff;">\&amp;cmd_dvorak</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> Irssi<span
style="color: #339933;">::</span><span
style="color: #006600;">command_bind</span><span
style="color: #009900;">&#40;</span><span
style="color: #ff0000;">'qw'</span><span
style="color: #339933;">,</span><span
style="color: #0000ff;">\&amp;cmd_qwerty</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> Irssi<span
style="color: #339933;">::</span><span
style="color: #006600;">signal_add</span><span
style="color: #009900;">&#40;</span><span
style="color: #ff0000;">'message public'</span><span
style="color: #339933;">,</span> <span
style="color: #000000; font-weight: bold;">sub</span> <span
style="color: #009900;">&#123;</span>dvorak_decode<span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$_</span><span
style="color: #009900;">&#91;</span><span
style="color: #cc66cc;">0</span><span
style="color: #009900;">&#93;</span><span
style="color: #339933;">,</span> <span
style="color: #0000ff;">$_</span><span
style="color: #009900;">&#91;</span><span
style="color: #cc66cc;">4</span><span
style="color: #009900;">&#93;</span><span
style="color: #339933;">,</span> <span
style="color: #0000ff;">$_</span><span
style="color: #009900;">&#91;</span><span
style="color: #cc66cc;">1</span><span
style="color: #009900;">&#93;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><span
style="color: #009900;">&#125;</span> <span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> Irssi<span
style="color: #339933;">::</span><span
style="color: #006600;">signal_add</span><span
style="color: #009900;">&#40;</span><span
style="color: #ff0000;">'message own_public'</span><span
style="color: #339933;">,</span> <span
style="color: #000000; font-weight: bold;">sub</span> <span
style="color: #009900;">&#123;</span>dvorak_decode<span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$_</span><span
style="color: #009900;">&#91;</span><span
style="color: #cc66cc;">0</span><span
style="color: #009900;">&#93;</span><span
style="color: #339933;">,</span> <span
style="color: #0000ff;">$_</span><span
style="color: #009900;">&#91;</span><span
style="color: #cc66cc;">2</span><span
style="color: #009900;">&#93;</span><span
style="color: #339933;">,</span> <span
style="color: #0000ff;">$_</span><span
style="color: #009900;">&#91;</span><span
style="color: #cc66cc;">1</span><span
style="color: #009900;">&#93;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><span
style="color: #009900;">&#125;</span> <span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> <span
style="color: #000066;">print</span> <span
style="color: #ff0000;">&quot;%B&gt;&gt;%n &quot;</span> <span
style="color: #339933;">.</span> <span
style="color: #0000ff;">$IRSSI</span><span
style="color: #009900;">&#123;</span>name<span
style="color: #009900;">&#125;</span> <span
style="color: #339933;">.</span> <span
style="color: #ff0000;">&quot; &quot;</span> <span
style="color: #339933;">.</span> <span
style="color: #0000ff;">$VERSION</span> <span
style="color: #339933;">.</span> <span
style="color: #ff0000;">&quot; loaded&quot;</span><span
style="color: #339933;">;</span></div></td></tr></tbody></table></div> ]]></content:encoded> <wfw:commentRss>http://pthree.org/2006/12/19/296/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>Optimizing Searches In Perl</title><link>http://pthree.org/2006/12/18/optimizing-searches-in-perl/</link> <comments>http://pthree.org/2006/12/18/optimizing-searches-in-perl/#comments</comments> <pubDate>Mon, 18 Dec 2006 20:51:29 +0000</pubDate> <dc:creator>Aaron</dc:creator> <category><![CDATA[Perl]]></category><guid
isPermaLink="false">http://www.pthree.org/2006/12/18/optimizing-searches-in-perl/</guid> <description><![CDATA[So, I needed something to search a string in one text file, and compare it with a string in a second text file. If there is a match, I need to print the results to a new text file. So, because I&#8217;m new to Perl, but have a programming background, I figured this would be [...]]]></description> <content:encoded><![CDATA[<p>So, I needed something to search a string in one text file, and compare it with a string in a second text file.  If there is a match, I need to print the results to a new text file.  So, because I&#8217;m new to Perl, but have a programming background, I figured this would be fairly easy, even if I&#8217;m not fluent with the language.  Rather than get into the nitty-gritty about the details, I&#8217;ll just show you what I did starting off:</p><div
class="codecolorer-container perl twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table
cellspacing="0" cellpadding="0"><tbody><tr><td
style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br
/>2<br
/>3<br
/>4<br
/>5<br
/>6<br
/>7<br
/>8<br
/>9<br
/>10<br
/>11<br
/>12<br
/>13<br
/>14<br
/>15<br
/>16<br
/>17<br
/>18<br
/>19<br
/>20<br
/>21<br
/>22<br
/>23<br
/>24<br
/>25<br
/>26<br
/>27<br
/>28<br
/>29<br
/></div></td><td><div
class="perl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span
style="color: #666666; font-style: italic;">#!/usr/bin/perl -w</span><br
/> <br
/> <span
style="color: #000066;">open</span><span
style="color: #009900;">&#40;</span>in1<span
style="color: #339933;">,</span> <span
style="color: #ff0000;">&quot;phones.dat&quot;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> <br
/> <span
style="color: #0000ff;">$counter</span> <span
style="color: #339933;">=</span> <span
style="color: #cc66cc;">1</span><span
style="color: #339933;">;</span><br
/> <br
/> <span
style="color: #b1b100;">while</span><span
style="color: #009900;">&#40;</span><span
style="color: #009999;">&lt;in1&gt;</span><span
style="color: #009900;">&#41;</span> <span
style="color: #666666; font-style: italic;"># &lt;/in1&gt;</span><br
/> <span
style="color: #009900;">&#123;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #0000ff;">$phone2</span> <span
style="color: #339933;">=</span> <span
style="color: #000066;">substr</span><span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$_</span><span
style="color: #339933;">,</span> <span
style="color: #cc66cc;">0</span><span
style="color: #339933;">,</span> <span
style="color: #cc66cc;">10</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #000066;">print</span> <span
style="color: #ff0000;">&quot;Match: 0&quot;</span> <span
style="color: #339933;">.</span> <span
style="color: #ff0000;">&quot;<span
style="color: #000099; font-weight: bold;">\r</span>&quot;</span><span
style="color: #339933;">;</span><br
/> <br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #000066;">open</span><span
style="color: #009900;">&#40;</span>in2<span
style="color: #339933;">,</span> <span
style="color: #ff0000;">&quot;/kdata/2006/1514/data/P1514.FIN&quot;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> <br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #b1b100;">while</span><span
style="color: #009900;">&#40;</span><span
style="color: #009999;">&lt;in2&gt;</span><span
style="color: #009900;">&#41;</span> <span
style="color: #666666; font-style: italic;">#&lt;/in2&gt;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #009900;">&#123;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #0000ff;">$phone1</span> <span
style="color: #339933;">=</span> <span
style="color: #000066;">substr</span><span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$_</span><span
style="color: #339933;">,</span> <span
style="color: #cc66cc;">1384</span><span
style="color: #339933;">,</span> <span
style="color: #cc66cc;">10</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> <br
/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #b1b100;">if</span><span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$phone1</span> <span
style="color: #339933;">==</span> <span
style="color: #0000ff;">$phone2</span><span
style="color: #009900;">&#41;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #009900;">&#123;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #000066;">print</span> <span
style="color: #ff0000;">&quot;Match: &quot;</span> <span
style="color: #339933;">.</span> <span
style="color: #0000ff;">$counter</span> <span
style="color: #339933;">.</span> <span
style="color: #ff0000;">&quot;<span
style="color: #000099; font-weight: bold;">\r</span>&quot;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #0000ff;">$counter</span><span
style="color: #339933;">++;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #009900;">&#125;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #009900;">&#125;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #000066;">close</span><span
style="color: #009900;">&#40;</span>in2<span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> <span
style="color: #009900;">&#125;</span><br
/> <br
/> <span
style="color: #000066;">print</span> <span
style="color: #ff0000;">&quot;<span
style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span
style="color: #339933;">;</span><br
/> <br
/> <span
style="color: #000066;">close</span><span
style="color: #009900;">&#40;</span>in1<span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span></div></td></tr></tbody></table></div><p>As you can see, this is a very inefficient algorithm.  If &#8220;phones.dat&#8221; is n-lines long, and &#8220;P1514.FIN&#8221; is m-lines long, then for every n-record, I am looking at EVERY m-record.  This means, my search algorithm is O(n*m).  Now, I&#8217;m going to say, that this works for small files.  Looking at &#8220;phones.dat&#8221; which only has 330 lines, and &#8220;P1514.FIN&#8221; which only has 500 lines, what am I worried about?  It takes less than a second to execute the code, and spit out the result.  Heh.  If only every file I dealt with was <em>that small</em>.  Today, I was looking at two files that had about 12,000 lines.  It took ~20 seconds to finish the script.  Still, not really a length that I have to be concerned about, but I can make it better.</p><p>First, thanks go to Levi Pearson and <a
href="http://halls.lug-nut.com/jayce/">Jason Hall</a> for helping me realize the errors of my ways.  I can increase the efficiency of the algorithm greatly by using hashes.  In fact, I can take the order of the algorithm to O(n+m) by only traversing each file only once.  Here&#8217;s the code I came up for that:</p><div
class="codecolorer-container perl twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table
cellspacing="0" cellpadding="0"><tbody><tr><td
style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br
/>2<br
/>3<br
/>4<br
/>5<br
/>6<br
/>7<br
/>8<br
/>9<br
/>10<br
/>11<br
/>12<br
/>13<br
/>14<br
/>15<br
/>16<br
/>17<br
/>18<br
/>19<br
/>20<br
/>21<br
/>22<br
/>23<br
/>24<br
/>25<br
/>26<br
/>27<br
/>28<br
/>29<br
/>30<br
/>31<br
/>32<br
/>33<br
/></div></td><td><div
class="perl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span
style="color: #666666; font-style: italic;">#!/usr/bin/perl -w</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp;<br
/> <span
style="color: #000066;">open</span><span
style="color: #009900;">&#40;</span>in<span
style="color: #339933;">,</span> <span
style="color: #ff0000;">&quot;P1514.FIN&quot;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp;<br
/> <span
style="color: #b1b100;">while</span><span
style="color: #009900;">&#40;</span><span
style="color: #009999;">&lt;in&gt;</span><span
style="color: #009900;">&#41;</span> <span
style="color: #666666; font-style: italic;"># &lt;/in&gt;</span><br
/> <span
style="color: #009900;">&#123;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #000066;">chomp</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #b1b100;">my</span> <span
style="color: #0000ff;">$layout</span> <span
style="color: #339933;">=</span> <span
style="color: #ff0000;">'@1384 A10'</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #b1b100;">my</span> <span
style="color: #0000ff;">$number</span> <span
style="color: #339933;">=</span> <span
style="color: #000066;">unpack</span> <span
style="color: #0000ff;">$layout</span><span
style="color: #339933;">,</span> <span
style="color: #0000ff;">$_</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp;<br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #0000ff;">$Phone</span><span
style="color: #009900;">&#123;</span><span
style="color: #0000ff;">$number</span><span
style="color: #009900;">&#125;</span> <span
style="color: #339933;">=</span> <span
style="color: #0000ff;">$_</span><span
style="color: #339933;">;</span><br
/> <span
style="color: #009900;">&#125;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp;<br
/> <span
style="color: #000066;">close</span><span
style="color: #009900;">&#40;</span>in<span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> <span
style="color: #000066;">open</span><span
style="color: #009900;">&#40;</span>in<span
style="color: #339933;">,</span> <span
style="color: #ff0000;">&quot;p1514.afo&quot;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> <br
/> <span
style="color: #0000ff;">$counter</span> <span
style="color: #339933;">=</span> <span
style="color: #cc66cc;">0</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp;<br
/> <span
style="color: #b1b100;">while</span><span
style="color: #009900;">&#40;</span><span
style="color: #009999;">&lt;in&gt;</span><span
style="color: #009900;">&#41;</span> <span
style="color: #666666; font-style: italic;">#&lt;/in&gt;</span><br
/> <span
style="color: #009900;">&#123;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #b1b100;">my</span> <span
style="color: #0000ff;">$layout</span> <span
style="color: #339933;">=</span> <span
style="color: #ff0000;">'@0 A10'</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #b1b100;">my</span> <span
style="color: #0000ff;">$number</span> <span
style="color: #339933;">=</span> <span
style="color: #000066;">unpack</span> <span
style="color: #0000ff;">$layout</span><span
style="color: #339933;">,</span> <span
style="color: #0000ff;">$_</span><span
style="color: #339933;">;</span><br
/> <br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #b1b100;">if</span> <span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$Phone</span><span
style="color: #009900;">&#123;</span><span
style="color: #0000ff;">$number</span><span
style="color: #009900;">&#125;</span><span
style="color: #009900;">&#41;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #009900;">&#123;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #000066;">print</span> <span
style="color: #ff0000;">&quot;Match: &quot;</span> <span
style="color: #339933;">.</span> <span
style="color: #0000ff;">$counter</span> <span
style="color: #339933;">.</span> <span
style="color: #ff0000;">&quot;<span
style="color: #000099; font-weight: bold;">\r</span>&quot;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #0000ff;">$counter</span><span
style="color: #339933;">++;</span><br
/> &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #009900;">&#125;</span><br
/> <span
style="color: #009900;">&#125;</span><br
/> <br
/> <span
style="color: #000066;">print</span> <span
style="color: #ff0000;">&quot;<span
style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span
style="color: #339933;">;</span><br
/> <br
/> <span
style="color: #000066;">close</span><span
style="color: #009900;">&#40;</span>in<span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span></div></td></tr></tbody></table></div><p>In this case, &#8220;P1514.FIN&#8221; still has the 500 lines it used to have, and &#8220;p1514.afo&#8221; has well over 12,000.  Executing the code is actually faster than previous.  We should expect this as rather than traversing the m-file n times making my comparison, I traverse each file only once.  The first file to store the key and value in a hash, and the second file to make the comparison.  The only thing that may make the program a bit more efficient, would be to store the smaller of the two files in the hash, and use the larger of the two for comparing against the hash.  But really, in that case, we&#8217;re just concerned about memory, which isn&#8217;t a worry for me.</p><p>The funny thing about this little programming example?  I&#8217;m applying what I&#8217;ve learned in Discrete Math to a very real everyday problem.  And who&#8217;d-a-thunk that any of the stuff was important?! <img
src='http://pthree.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p> ]]></content:encoded> <wfw:commentRss>http://pthree.org/2006/12/18/optimizing-searches-in-perl/feed/</wfw:commentRss> <slash:comments>8</slash:comments> </item> <item><title>&#8220;We&#8217;re Going In A New Direction&#8221;</title><link>http://pthree.org/2006/12/16/were-going-in-a-new-direction/</link> <comments>http://pthree.org/2006/12/16/were-going-in-a-new-direction/#comments</comments> <pubDate>Sat, 16 Dec 2006 18:30:06 +0000</pubDate> <dc:creator>Aaron</dc:creator> <category><![CDATA[PHP]]></category> <category><![CDATA[Perl]]></category> <category><![CDATA[Python]]></category><guid
isPermaLink="false">http://www.pthree.org/2006/12/16/were-going-in-a-new-direction/</guid> <description><![CDATA[Looking back at the archives of this blog, it&#8217;s overall theme and vibrancy has changed throughout the months, and honestly, I don&#8217;t like where it&#8217;s landed. So, this blog is taking a new turn and revisiting it&#8217;s roots. The initial reason this blog was put up, back in September 2005, was to provide an archive [...]]]></description> <content:encoded><![CDATA[<p>Looking back at the archives of this blog, it&#8217;s overall theme and vibrancy has changed throughout the months, and honestly, I don&#8217;t like where it&#8217;s landed.  So, this blog is taking a new turn and revisiting it&#8217;s roots.</p><p>The initial reason this blog was put up, back in September 2005, was to provide an archive to <strong>P</strong>erl, <strong>P</strong>ython and <strong>P</strong>HP (thus, the &#8220;Pthree&#8221;).   It was to take a look at those languages from a scripting point of view.  Being fairly new in all 3, I thought this would provide great tutorials to those languages for those who are also new to those languages.  More importantly, it was to keep me working with those languages to improve my programming prowess.  Well, it took a different direction, and it didn&#8217;t take long either.</p><p>I&#8217;d like to go back to what this blog was initially designed for, and provide my experience in looking at those three languages.  However, I admit that I am intimidated by the expertise of those out in the &#8220;real world&#8221;.  I fear that my experiences will be ridiculed by those of greater experience and knowledge.  However, I&#8217;m going to take a step in the dark, and brave the journey.  Starting tomorrow, the overall content of the blog will be in respects to Perl, Python and PHP with touches of Ruby and Bash all on GNU/Linux systems, primarily Ubuntu.  Of course, comments are always open, and I encourage those of higher knowledge to help me identify what to fix or improve with my code.  I plan to have a post up per day at a minimum.</p><p>This means that I&#8217;ll need a good syntax highlighter for my blog.  I have been using <a
href="http://qbnz.com/highlighter/">Geshi</a>, and like it so far, but it needs a little tweaking.  If anyone knows of a solid syntax highlighter, which cover the above languages, for the WordPress platform, I&#8217;m all ears.</p><p>I hope you enjoy the direction this blog takes.</p> ]]></content:encoded> <wfw:commentRss>http://pthree.org/2006/12/16/were-going-in-a-new-direction/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Perl, substr, and line feeds</title><link>http://pthree.org/2006/11/22/perl-substr-and-line-feeds/</link> <comments>http://pthree.org/2006/11/22/perl-substr-and-line-feeds/#comments</comments> <pubDate>Wed, 22 Nov 2006 14:46:57 +0000</pubDate> <dc:creator>Aaron</dc:creator> <category><![CDATA[Perl]]></category><guid
isPermaLink="false">http://www.pthree.org/2006/11/22/perl-substr-and-line-feeds/</guid> <description><![CDATA[Ok. This may come to most of you as &#8220;DUH&#8221;, but for me and a few helping me, we couldn&#8217;t figure it out. Consider the following Perl code: 123456789101112131415!#/usr/bin/perl -w open&#40;IN, &#34;oldfile.txt&#34;&#41;; open&#40;OUT, &#34;&#38;gt;newfile.txt&#34;&#41;; while&#40;&#38;lt;IN&#38;gt;&#41; &#123; &#160; &#160; $var1=substr&#40;$_, 0, 10&#41;; &#160; &#160; $var2=substr&#40;$_, 10, 5&#41;; &#160; &#160; $var3=substr&#40;$_, 15, 3&#41;; &#160; &#160; substr&#40;$_, 0, [...]]]></description> <content:encoded><![CDATA[<p>Ok.  This may come to most of you as &#8220;DUH&#8221;, but for me and a few helping me, we couldn&#8217;t figure it out.  Consider the following Perl code:</p><div
class="codecolorer-container perl twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table
cellspacing="0" cellpadding="0"><tbody><tr><td
style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br
/>2<br
/>3<br
/>4<br
/>5<br
/>6<br
/>7<br
/>8<br
/>9<br
/>10<br
/>11<br
/>12<br
/>13<br
/>14<br
/>15<br
/></div></td><td><div
class="perl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span
style="color: #339933;">!</span><span
style="color: #666666; font-style: italic;">#/usr/bin/perl -w</span><br
/> <span
style="color: #000066;">open</span><span
style="color: #009900;">&#40;</span>IN<span
style="color: #339933;">,</span> <span
style="color: #ff0000;">&quot;oldfile.txt&quot;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> <span
style="color: #000066;">open</span><span
style="color: #009900;">&#40;</span>OUT<span
style="color: #339933;">,</span> <span
style="color: #ff0000;">&quot;&amp;gt;newfile.txt&quot;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> <span
style="color: #b1b100;">while</span><span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">&amp;lt</span><span
style="color: #339933;">;</span>IN<span
style="color: #0000ff;">&amp;gt</span><span
style="color: #339933;">;</span><span
style="color: #009900;">&#41;</span><br
/> <span
style="color: #009900;">&#123;</span><br
/> &nbsp; &nbsp; <span
style="color: #0000ff;">$var1</span><span
style="color: #339933;">=</span><span
style="color: #000066;">substr</span><span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$_</span><span
style="color: #339933;">,</span> <span
style="color: #cc66cc;">0</span><span
style="color: #339933;">,</span> <span
style="color: #cc66cc;">10</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; <span
style="color: #0000ff;">$var2</span><span
style="color: #339933;">=</span><span
style="color: #000066;">substr</span><span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$_</span><span
style="color: #339933;">,</span> <span
style="color: #cc66cc;">10</span><span
style="color: #339933;">,</span> <span
style="color: #cc66cc;">5</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; <span
style="color: #0000ff;">$var3</span><span
style="color: #339933;">=</span><span
style="color: #000066;">substr</span><span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$_</span><span
style="color: #339933;">,</span> <span
style="color: #cc66cc;">15</span><span
style="color: #339933;">,</span> <span
style="color: #cc66cc;">3</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; <span
style="color: #000066;">substr</span><span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$_</span><span
style="color: #339933;">,</span> <span
style="color: #cc66cc;">0</span><span
style="color: #339933;">,</span> <span
style="color: #cc66cc;">3</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">=</span><span
style="color: #0000ff;">$var3</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; <span
style="color: #000066;">substr</span><span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$_</span><span
style="color: #339933;">,</span> <span
style="color: #cc66cc;">3</span><span
style="color: #339933;">,</span> <span
style="color: #cc66cc;">10</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">=</span><span
style="color: #0000ff;">$var1</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; <span
style="color: #000066;">substr</span><span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$_</span><span
style="color: #339933;">,</span> <span
style="color: #cc66cc;">13</span><span
style="color: #339933;">,</span> <span
style="color: #cc66cc;">5</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">=</span><span
style="color: #0000ff;">$var2</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; <span
style="color: #000066;">print</span> OUT <span
style="color: #0000ff;">$_</span><span
style="color: #339933;">;</span><br
/> <span
style="color: #009900;">&#125;</span><br
/> <span
style="color: #000066;">close</span><span
style="color: #009900;">&#40;</span>IN<span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> <span
style="color: #000066;">close</span><span
style="color: #009900;">&#40;</span>OUT<span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span></div></td></tr></tbody></table></div><p>Fairly straight forward.  Nothing fancy here.  I&#8217;ve assigned 3 variables some text from the current line, and rearranged their order, then printed out the new order to <em>newfile.txt</em>.  If <em>oldfile.txt</em> is 100 characters long on each line, and 500 lines long, then <em>newfile.txt</em> is also 100 characters long on each line and 500 lines long.</p><p>However, what if I only want to print the first 18 characters on each line to be in <em>newfile.txt</em> rather than the whole line?  Than rather than:</p><div
class="codecolorer-container perl twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table
cellspacing="0" cellpadding="0"><tbody><tr><td
style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br
/></div></td><td><div
class="perl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span
style="color: #000066;">print</span> OUT <span
style="color: #0000ff;">$_</span><span
style="color: #339933;">;</span></div></td></tr></tbody></table></div><p>I would need:</p><div
class="codecolorer-container perl twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table
cellspacing="0" cellpadding="0"><tbody><tr><td
style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br
/></div></td><td><div
class="perl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span
style="color: #000066;">print</span> OUT <span
style="color: #000066;">substr</span><span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$_</span><span
style="color: #339933;">,</span> <span
style="color: #cc66cc;">0</span><span
style="color: #339933;">,</span> <span
style="color: #cc66cc;">18</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span></div></td></tr></tbody></table></div><p>Ah.  But do you notice anything wrong with the code above?  I didn&#8217;t, and it took 8 hours of sleep later to figure it out.  When printing out the whole line <em>($_)</em>, the line feed as the last character on that line.  Thus, <em>newfile.txt</em> will also have the line feed.  However, if using <em>substr()</em> in the middle of the line, not including the last character of the line (the line feed), then the line feed doesn&#8217;t exist, and Perl attempts to write every line on the same line.  So, rather, we need to append a line feed at the end:</p><div
class="codecolorer-container perl twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table
cellspacing="0" cellpadding="0"><tbody><tr><td
style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br
/></div></td><td><div
class="perl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span
style="color: #000066;">print</span> OUT <span
style="color: #000066;">substr</span><span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$_</span><span
style="color: #339933;">,</span> <span
style="color: #cc66cc;">0</span><span
style="color: #339933;">,</span> <span
style="color: #cc66cc;">18</span><span
style="color: #009900;">&#41;</span> <span
style="color: #339933;">.</span> <span
style="color: #ff0000;">&quot;<span
style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span
style="color: #339933;">;</span></div></td></tr></tbody></table></div><p>Much better.  Something so simple, yet easily overlooked.</p> ]]></content:encoded> <wfw:commentRss>http://pthree.org/2006/11/22/perl-substr-and-line-feeds/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Binary Timestamp Screenshot</title><link>http://pthree.org/2006/08/27/binary-timestamp-screenshot/</link> <comments>http://pthree.org/2006/08/27/binary-timestamp-screenshot/#comments</comments> <pubDate>Sun, 27 Aug 2006 22:05:32 +0000</pubDate> <dc:creator>Aaron</dc:creator> <category><![CDATA[Perl]]></category> <category><![CDATA[Scripting]]></category><guid
isPermaLink="false">http://www.pthree.org/2006/08/27/binary-timestamp-screenshot/</guid> <description><![CDATA[I was way too tired last night to whip up a screenshot, so you could see the binary_time.pl script in action. So, here it is in a seperate post. Enjoy.]]></description> <content:encoded><![CDATA[<p>I was way too tired last night to whip up a screenshot, so you could see the binary_time.pl script in action.  So, here it is in a seperate post.  Enjoy.</p><p><center><br
/> <img
src="http://www.pthree.org/wp-content/uploads/2006/08/binary_snapshot.png" alt="Binary Timestamp Screenshot" hspace="15" vspace="15" /><br
/></center></p> ]]></content:encoded> <wfw:commentRss>http://pthree.org/2006/08/27/binary-timestamp-screenshot/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>My First Irssi Script- Binary Timestamps</title><link>http://pthree.org/2006/08/27/my-first-irssi-script-binary-timestamps/</link> <comments>http://pthree.org/2006/08/27/my-first-irssi-script-binary-timestamps/#comments</comments> <pubDate>Sun, 27 Aug 2006 07:37:11 +0000</pubDate> <dc:creator>Aaron</dc:creator> <category><![CDATA[Perl]]></category> <category><![CDATA[Scripting]]></category><guid
isPermaLink="false">http://www.pthree.org/2006/08/27/my-first-irssi-script-binary-timestamps/</guid> <description><![CDATA[A couple nights ago, while on Freenode, lilo (Rob Levin) posted a small log of a chat in the channel, and I noticed that he was using the Unix Epoch time as his timestamp in his IRC client irssi. I thought that was genious, so I set out to code an irssi script that shows [...]]]></description> <content:encoded><![CDATA[<p>A couple nights ago, while on Freenode, lilo (Rob Levin) posted a small log of a chat in the channel, and I noticed that he was using the Unix Epoch time as his timestamp in his IRC client irssi.  I thought that was genious, so I set out to code an irssi script that shows binary timestamps.  Seeing as though I am still relatively new to Perl, I knew this would be a challenge, but I figured it wasn&#8217;t too difficult to handle.  So today, I set out to code such a script.</p><p>The first thing for me, again, because of my n00b skills, was to create a stand-alone program that converted the system time to a binary string representation.  I wanted to test and retest that the conversion worked perfectly before testing it in irssi and crashing the program.</p><p>So here was what I had in mind:</p><ol><li>Get the hours and minutes from the localtime on the system.</li><li>Convert the hours to a binary string.</li><li>Convert the minuts to a binary string.</li><li>Concatenate the binary strings together with the colon time seperator.</li><li>Store the concatention in the irssi timestamp variable.</li></ol><p>The first four steps took no time at all.  I could print them to the console and see the results.  The wall that I hit was trying to hook it into irssi.  I had no idea where to begin with that.  So I figured I&#8217;d start looking at other scripts, and figure out exactly how to do it.  There was also documentation on the irssi web site for creating brief scripts.  Needless to say, it isn&#8217;t that comprhensive, and I spend more time hacking than learning.  I can easily say that learning the syntax and functions took 80% of the time getting this script finished.</p><p>Well, it&#8217;s finished.  It&#8217;s a fairly easy and brief script.  Nothing to it really.  You can download the <a
href="http://www.pthree.org/wp-content/uploads/2006/08/binary_time.pl">whole script here</a>.  To execute the script, just <em>/script load binary_time.pl</em> and to unload the script, just <em>/script unload binary_time</em>.  I would be interested in feedback on the script, if you wouldn&#8217;t mind testing it out.</p><p>Also, I received a couple emails and a comment on the last post regarding my hacked madcow theme, and if I could post it here.  Sure, no problem. <a
href="http://www.pthree.org/wp-content/uploads/2006/08/madcow.theme">Here you go</a>.</p> ]]></content:encoded> <wfw:commentRss>http://pthree.org/2006/08/27/my-first-irssi-script-binary-timestamps/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>Pimped Irssi</title><link>http://pthree.org/2006/08/24/pimped-irssi/</link> <comments>http://pthree.org/2006/08/24/pimped-irssi/#comments</comments> <pubDate>Thu, 24 Aug 2006 22:02:25 +0000</pubDate> <dc:creator>Aaron</dc:creator> <category><![CDATA[Perl]]></category> <category><![CDATA[Scripting]]></category><guid
isPermaLink="false">http://www.pthree.org/2006/08/24/pimped-irssi/</guid> <description><![CDATA[Below is a screenshot (click on it for a full-sized shot) of my current irssi setup. The visibles are as follows: nicklist.pl perl script for the nicklist on the right. It is redrawn on screen for every part/join and every channel change. Really nice. I run it in screen mode rather than fifo mode. I [...]]]></description> <content:encoded><![CDATA[<p>Below is a screenshot (click on it for a full-sized shot) of my current irssi setup.  The visibles are as follows:</p><ul><li><a
href="http://wouter.coekaerts.be/site/irssi/nicklist">nicklist.pl</a> perl script for the nicklist on the right.  It is redrawn on screen for every part/join and every channel change.  Really nice.  I run it in screen mode rather than fifo mode.  I would rather deal with one terminal than two.</li><li><a
href="http://www.irssi.org/themefiles/madcow.theme">madcow.theme</a> as my main irssi theme.  Yes, even though irssi is a console application, there are themes to customize the look.  I like madcow the best.  It has a tight overall theme integration, and the indented nicks on the left are a must.  The colors work well with each other and they are strong.</li><li><a
href="http://f0rked.com/articles/irssisplit">Split windows</a> are the only way to go with irssi.  As pictured, I have 3 containers managing the channels (windows) that I am in.  This way, I can keep updated on the channels that I frequent the most (I&#8217;m in 16 channels on freenode currently).  The only problem is being able to know what window you are in before sending a message.</li><li>Theme hacking for split windows is a must.  With the default theme, it difficult to know what channel you are in.  You have to look at the status bar, and see where it is located before sending.  This isn&#8217;t enough, so I made the active status bar bright red as a better visual clue to where I am.  Since hacking this in the theme, I haven&#8217;t sent a message to the wrong channel.  Also, if anyone says my nick at all, the whole line is yellow, versus just my nick getting highlighted.  A little more obvious when focusing on 3 windows at once.</li></ul><p><center><a
href="http://www.pthree.org/wp-content/uploads/2006/08/pimped_irssi.png"><br
/> <img
src="http://www.pthree.org/wp-content/uploads/2006/08/pimped_irssi_thumb.png" border="1" /></a><br
/></center></p> ]]></content:encoded> <wfw:commentRss>http://pthree.org/2006/08/24/pimped-irssi/feed/</wfw:commentRss> <slash:comments>6</slash:comments> </item> <item><title>New Perl Project</title><link>http://pthree.org/2005/11/14/new-perl-project/</link> <comments>http://pthree.org/2005/11/14/new-perl-project/#comments</comments> <pubDate>Mon, 14 Nov 2005 15:08:41 +0000</pubDate> <dc:creator>Aaron</dc:creator> <category><![CDATA[(X)HTML]]></category> <category><![CDATA[Perl]]></category><guid
isPermaLink="false">http://www.pthree.org:8080/?p=19</guid> <description><![CDATA[Browsing the web, I have seen a number of different ways to &#8220;hide&#8221; email addresses on web pages from bots. I have seen images, slight text obfuscation and other methods. However, has anyone thought of HTML obfuscation? It&#8217;s a simple concept really, using the ASCII chart to &#8220;hide&#8221; your letters. Consider the ASCII table below: [...]]]></description> <content:encoded><![CDATA[<p>Browsing the web, I have seen a number of different ways to &#8220;hide&#8221; email addresses on web pages from bots.  I have seen images, slight text obfuscation and other methods.  However, has anyone thought of HTML obfuscation?  It&#8217;s a simple concept really, using the ASCII chart to &#8220;hide&#8221; your letters.  Consider the ASCII table below:</p><pre>
       Decimal   Octal   Hex    Binary     Value
       -------   -----   ---    ------     -----
         000      000    000   00000000      NUL    (Null char.)
         001      001    001   00000001      SOH    (Start of Header)
         002      002    002   00000010      STX    (Start of Text)
         003      003    003   00000011      ETX    (End of Text)
         004      004    004   00000100      EOT    (End of Transmission)
         005      005    005   00000101      ENQ    (Enquiry)
         006      006    006   00000110      ACK    (Acknowledgment)
         007      007    007   00000111      BEL    (Bell)
         008      010    008   00001000       BS    (Backspace)
         009      011    009   00001001       HT    (Horizontal Tab)
         010      012    00A   00001010       LF    (Line Feed)
         011      013    00B   00001011       VT    (Vertical Tab)
         012      014    00C   00001100       FF    (Form Feed)
         013      015    00D   00001101       CR    (Carriage Return)
         014      016    00E   00001110       SO    (Shift Out)
         015      017    00F   00001111       SI    (Shift In)
         016      020    010   00010000      DLE    (Data Link Escape)
         017      021    011   00010001      DC1 (XON) (Device Control 1)
         018      022    012   00010010      DC2       (Device Control 2)
         019      023    013   00010011      DC3 (XOFF)(Device Control 3)
         020      024    014   00010100      DC4       (Device Control 4)
         021      025    015   00010101      NAK    (Negative Acknowledgement)
         022      026    016   00010110      SYN    (Synchronous Idle)
         023      027    017   00010111      ETB    (End of Trans. Block)
         024      030    018   00011000      CAN    (Cancel)
         025      031    019   00011001       EM    (End of Medium)
         026      032    01A   00011010      SUB    (Substitute)
         027      033    01B   00011011      ESC    (Escape)
         028      034    01C   00011100       FS    (File Separator)
         029      035    01D   00011101       GS    (Group Separator)
         030      036    01E   00011110       RS    (Request to Send)(Record Separator)
         031      037    01F   00011111       US    (Unit Separator)
         032      040    020   00100000       SP    (Space)
         033      041    021   00100001        !    (exclamation mark)
         034      042    022   00100010        "    (double quote)
         035      043    023   00100011        #    (number sign)
         036      044    024   00100100        $    (dollar sign)
         037      045    025   00100101        %    (percent)
         038      046    026   00100110        &#038;    (ampersand)
         039      047    027   00100111        '    (single quote)
         040      050    028   00101000        (    (left/opening parenthesis)
         041      051    029   00101001        )    (right/closing parenthesis)
         042      052    02A   00101010        *    (asterisk)
         043      053    02B   00101011        +    (plus)
         044      054    02C   00101100        ,    (comma)
         045      055    02D   00101101        -    (minus or dash)
         046      056    02E   00101110        .    (dot)
         047      057    02F   00101111        /    (forward slash)
         048      060    030   00110000        0
         049      061    031   00110001        1
         050      062    032   00110010        2
         051      063    033   00110011        3
         052      064    034   00110100        4
         053      065    035   00110101        5
         054      066    036   00110110        6
         055      067    037   00110111        7
         056      070    038   00111000        8
         057      071    039   00111001        9
         058      072    03A   00111010        :    (colon)
         059      073    03B   00111011        ;    (semi-colon)
         060      074    03C   00111100        &#60;    (less than)
         061      075    03D   00111101        =    (equal sign)
         062      076    03E   00111110        &#62;    (greater than)
         063      077    03F   00111111        ?    (question mark)
         064      100    040   01000000        @    (AT symbol)
         065      101    041   01000001        A
         066      102    042   01000010        B
         067      103    043   01000011        C
         068      104    044   01000100        D
         069      105    045   01000101        E
         070      106    046   01000110        F
         071      107    047   01000111        G
         072      110    048   01001000        H
         073      111    049   01001001        I
         074      112    04A   01001010        J
         075      113    04B   01001011        K
         076      114    04C   01001100        L
         077      115    04D   01001101        M
         078      116    04E   01001110        N
         079      117    04F   01001111        O
         080      120    050   01010000        P
         081      121    051   01010001        Q
         082      122    052   01010010        R
         083      123    053   01010011        S
         084      124    054   01010100        T
         085      125    055   01010101        U
         086      126    056   01010110        V
         087      127    057   01010111        W
         088      130    058   01011000        X
         089      131    059   01011001        Y
         090      132    05A   01011010        Z
         091      133    05B   01011011        [    (left/opening bracket)
         092      134    05C   01011100        \    (back slash)
         093      135    05D   01011101        ]    (right/closing bracket)
         094      136    05E   01011110        ^    (caret/cirumflex)
         095      137    05F   01011111        _    (underscore)
         096      140    060   01100000        `
         097      141    061   01100001        a
         098      142    062   01100010        b
         099      143    063   01100011        c
         100      144    064   01100100        d
         101      145    065   01100101        e
         102      146    066   01100110        f
         103      147    067   01100111        g
         104      150    068   01101000        h
         105      151    069   01101001        i
         106      152    06A   01101010        j
         107      153    06B   01101011        k
         108      154    06C   01101100        l
         109      155    06D   01101101        m
         110      156    06E   01101110        n
         111      157    06F   01101111        o
         112      160    070   01110000        p
         113      161    071   01110001        q
         114      162    072   01110010        r
         115      163    073   01110011        s
         116      164    074   01110100        t
         117      165    075   01110101        u
         118      166    076   01110110        v
         119      167    077   01110111        w
         120      170    078   01111000        x
         121      171    079   01111001        y
         122      172    07A   01111010        z
         123      173    07B   01111011        {    (left/opening brace)
         124      174    07C   01111100        |    (vertical bar)
         125      175    07D   01111101        }    (right/closing brace)
         126      176    07E   01111110        ~    (tilde)
         127      177    07F   01111111      DEL    (delete)
</pre><p>Taking the decimal value and adding a &#8220;&#038;&#8221; and a &#8220;#&#8221; before the number, and a &#8220;;&#8221; after it, results in the HTML code for that ASCII value.  For example, my email address would be as follows (broken-up over a couple of lines to fit better on pages with smaller screen resolutions):</p><div
class="codecolorer-container text twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table
cellspacing="0" cellpadding="0"><tbody><tr><td
style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br
/>2<br
/></div></td><td><div
class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&amp;#38;&amp;#35;97;&amp;#38;&amp;#35;97;&amp;#38;&amp;#35;114;&amp;#38;&amp;#35;111;&amp;#38;&amp;#35;110;&amp;#38;&amp;#35;46;&amp;#38;&amp;#35;116;&amp;#38;&amp;#35;111;&amp;#38;&amp;#35;112;&amp;#38;&amp;#35;111;&amp;#38;&amp;#35;110;&amp;#38;&amp;#35;99;<br
/> &amp;#38;&amp;#35;101;&amp;#38;&amp;#35;64;&amp;#38;&amp;#35;103;&amp;#38;&amp;#35;109;&amp;#38;&amp;#35;97;&amp;#38;&amp;#35;105;&amp;#38;&amp;#35;108;&amp;#38;&amp;#35;46;&amp;#38;&amp;#35;99;&amp;#38;&amp;#35;111;&amp;#38;&amp;#35;109;</div></td></tr></tbody></table></div><p>Now tell me that web bots are going to make sense of that.  Becuase bots scan the source code of the HTML rather than the parsed code, you can rest assured that your email address will remain secure from spam and the such.</p><p>Becuase of this new found idea I had over the weekend (I doubt it is <em>that</em> new- I am sure someone else thought of this as well), I decided that I will be coding a simple HTML page with forms that will parse any ASCII character into the HTML obfuscated code.  I only see this useful for hiding email addresses on web pages, and making web pages W3C compliant.  I decided to use Perl as my language of choice.  This page should be quick to code, including the Perl script.  When the code is complete, I will post the results online, for all to use and share.</p> ]]></content:encoded> <wfw:commentRss>http://pthree.org/2005/11/14/new-perl-project/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Converting QuickBasic to Perl at work</title><link>http://pthree.org/2005/10/02/converting-quickbasic-to-perl-at-work/</link> <comments>http://pthree.org/2005/10/02/converting-quickbasic-to-perl-at-work/#comments</comments> <pubDate>Mon, 03 Oct 2005 01:05:30 +0000</pubDate> <dc:creator>Aaron</dc:creator> <category><![CDATA[Linux]]></category> <category><![CDATA[Perl]]></category><guid
isPermaLink="false">http://www.pthree.org:8080/?p=8</guid> <description><![CDATA[At work, most of our software programs run in Linux. We do use Windows XP workstations, however. We use PuTTY to access Linux. It works well, and the IT department as well as most of the data engineers. The only thing that is keeping us from making the switch is QuickBasic. Several years ago, a [...]]]></description> <content:encoded><![CDATA[<p>At work, most of our software programs run in Linux.  We do use Windows XP workstations, however.  We use PuTTY to access Linux.  It works well, and the IT department as well as <em>most</em> of the data engineers.  The only thing that is keeping us from making the switch is QuickBasic.</p><p>Several years ago, a former employee wrote a few batch files utilizing the QuickBasic language.  At the time, it worked well, and it still is.  However, the more we use Linux, the more we see the sheer power it offers, and getting rid of a lot of Windows and other licenses is optimal.  So I decided to take it upon myself to make the conversion.</p><p>Fortunately, there isn&#8217;t much in the QuickBasic realm at work that I need to deal with.  All of them just read plain text files, make some adjustments, and spit out the result into a new text file.  And luckily, there are only a handful of these programs to worry about.</p><p>The only drawback to making this switch is the macros that a few of the data engineers have grown accustomed to.  Also, these employees have become familiar with the language, so altering the Basic program to fit their certain circumstances isn&#8217;t too difficult.  This could mean trouble when moving to a new language for a few reasons.  First, the new language will need some tutoring and training before making the switch.  Next, the macros everyone has grown to love will disappear, unless smaller Perl or Python scripts can be written to replace those macros.  Finally, these programs would need to be bullet-proof.  Due to the manipulation of <em>extremely</em> valuable data, bugs would have to be 100% worked out before implementation.</p><p>Weighing the benifits versus the drawbacks, however, seem to be clear.  If the goal of the company is to move to everything Linux, even for workstations, then a new language will need to a replace the existing Windows-only QuickBasic programs.  Perl has low overhead and utilized little processing power.  It is an easy language to grasp, and an easy language to write &#8220;quickies&#8221;.</p><p>While I have no code yet, I do plan on attempting the conversion this week, which means I&#8217;ll have some code and tutorials up soon.</p> ]]></content:encoded> <wfw:commentRss>http://pthree.org/2005/10/02/converting-quickbasic-to-perl-at-work/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Perl Obfuscated Code</title><link>http://pthree.org/2005/09/30/perl-camel-code/</link> <comments>http://pthree.org/2005/09/30/perl-camel-code/#comments</comments> <pubDate>Sat, 01 Oct 2005 05:27:26 +0000</pubDate> <dc:creator>Aaron</dc:creator> <category><![CDATA[Perl]]></category><guid
isPermaLink="false">http://www.pthree.org:8080/?p=4</guid> <description><![CDATA[One of the fun features about Perl is obfuscating code. You can make the simple &#8220;Hello World&#8221; much more difficult than it should be. This is definitely one of the fun features of programming Perl. For example, from Wikipedia, here is a program that prints out &#8220;Just another Perl / Unix hacker&#8221; using 32 concurrent [...]]]></description> <content:encoded><![CDATA[<p>One of the fun features about Perl is obfuscating code.  You can make the simple &#8220;Hello World&#8221; much more difficult than it should be.  This is definitely one of the fun features of programming Perl.  For example, from Wikipedia, here is a program that prints out &#8220;Just another Perl / Unix hacker&#8221; using 32 concurrent processes.  How cool is that?</p><div
class="codecolorer-container perl twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table
cellspacing="0" cellpadding="0"><tbody><tr><td
style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br
/>2<br
/>3<br
/>4<br
/></div></td><td><div
class="perl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span
style="color: #0000ff;">@P</span><span
style="color: #339933;">=</span><span
style="color: #000066;">split</span><span
style="color: #339933;">//,</span><span
style="color: #ff0000;">&quot;.URRUU<span
style="color: #000099; font-weight: bold;">\c</span>8R&quot;</span><span
style="color: #339933;">;</span><span
style="color: #0000ff;">@d</span><span
style="color: #339933;">=</span><span
style="color: #000066;">split</span><span
style="color: #339933;">//,</span><span
style="color: #ff0000;">&quot;<span
style="color: #000099; font-weight: bold;">\n</span>rekcah xinU / lreP rehtona tsuJ&quot;</span><span
style="color: #339933;">;</span>sub p<span
style="color: #009900;">&#123;</span><br
/> <span
style="color: #0000ff;">@p</span><span
style="color: #009900;">&#123;</span><span
style="color: #ff0000;">&quot;r$p&quot;</span><span
style="color: #339933;">,</span><span
style="color: #ff0000;">&quot;u$p&quot;</span><span
style="color: #009900;">&#125;</span><span
style="color: #339933;">=</span><span
style="color: #009900;">&#40;</span>P<span
style="color: #339933;">,</span>P<span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span>pipe<span
style="color: #ff0000;">&quot;r$p&quot;</span><span
style="color: #339933;">,</span><span
style="color: #ff0000;">&quot;u$p&quot;</span><span
style="color: #339933;">;++</span><span
style="color: #0000ff;">$p</span><span
style="color: #339933;">;</span><span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$q</span><span
style="color: #339933;">*=</span><span
style="color: #cc66cc;">2</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">+=</span><span
style="color: #0000ff;">$f</span><span
style="color: #339933;">=!</span><span
style="color: #000066;">fork</span><span
style="color: #339933;">;</span>map<span
style="color: #009900;">&#123;</span><span
style="color: #0000ff;">$P</span><span
style="color: #339933;">=</span><span
style="color: #0000ff;">$P</span><span
style="color: #009900;">&#91;</span><span
style="color: #0000ff;">$f</span><span
style="color: #339933;">^</span>ord<br
/> <span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$p</span><span
style="color: #009900;">&#123;</span><span
style="color: #0000ff;">$_</span><span
style="color: #009900;">&#125;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">&amp;</span><span
style="color: #cc66cc;">6</span><span
style="color: #009900;">&#93;</span><span
style="color: #339933;">;</span><span
style="color: #0000ff;">$p</span><span
style="color: #009900;">&#123;</span><span
style="color: #0000ff;">$_</span><span
style="color: #009900;">&#125;</span><span
style="color: #339933;">=/</span> <span
style="color: #339933;">^</span><span
style="color: #0000ff;">$P</span><span
style="color: #339933;">/</span>ix<span
style="color: #339933;">?</span><span
style="color: #0000ff;">$P</span><span
style="color: #339933;">:</span><span
style="color: #000066;">close</span><span
style="color: #0000ff;">$_</span><span
style="color: #009900;">&#125;</span>keys<span
style="color: #0000ff;">%p</span><span
style="color: #009900;">&#125;</span>p<span
style="color: #339933;">;</span>p<span
style="color: #339933;">;</span>p<span
style="color: #339933;">;</span>p<span
style="color: #339933;">;</span>p<span
style="color: #339933;">;</span>map<span
style="color: #009900;">&#123;</span><span
style="color: #0000ff;">$p</span><span
style="color: #009900;">&#123;</span><span
style="color: #0000ff;">$_</span><span
style="color: #009900;">&#125;</span><span
style="color: #339933;">=~/^</span><span
style="color: #009900;">&#91;</span>P<span
style="color: #339933;">.</span><span
style="color: #009900;">&#93;</span><span
style="color: #339933;">/</span><span
style="color: #0000ff;">&amp;amp</span><span
style="color: #339933;">;</span><span
style="color: #0000ff;">&amp;amp</span><span
style="color: #339933;">;</span><br
/> <span
style="color: #000066;">close</span><span
style="color: #0000ff;">$_</span><span
style="color: #009900;">&#125;</span><span
style="color: #0000ff;">%p</span><span
style="color: #339933;">;</span>wait <span
style="color: #b1b100;">until</span><span
style="color: #0000ff;">$?</span><span
style="color: #339933;">;</span>map<span
style="color: #009900;">&#123;</span><span
style="color: #339933;">/^</span>r<span
style="color: #339933;">/</span><span
style="color: #0000ff;">&amp;amp</span><span
style="color: #339933;">;</span><span
style="color: #0000ff;">&amp;amp</span><span
style="color: #339933;">;</span><span
style="color: #0000ff;">&amp;lt</span><span
style="color: #339933;">;</span> <span
style="color: #0000ff;">$_</span><span
style="color: #0000ff;">&amp;gt</span><span
style="color: #339933;">;</span><span
style="color: #009900;">&#125;</span><span
style="color: #0000ff;">%p</span><span
style="color: #339933;">;</span><span
style="color: #0000ff;">$_</span><span
style="color: #339933;">=</span><span
style="color: #0000ff;">$d</span><span
style="color: #009900;">&#91;</span><span
style="color: #0000ff;">$q</span><span
style="color: #009900;">&#93;</span><span
style="color: #339933;">;</span>sleep <span
style="color: #000066;">rand</span><span
style="color: #009900;">&#40;</span><span
style="color: #cc66cc;">2</span><span
style="color: #009900;">&#41;</span><span
style="color: #b1b100;">if</span><span
style="color: #339933;">/</span><span
style="color: #0000ff;">\S</span><span
style="color: #339933;">/;</span>print</div></td></tr></tbody></table></div><p>Unfortuantely, this program only took 2nd in a obfuscated code contest.  According to the author on <a
href="http://perl.plover.com/obfuscated/">his website</a>:</p><blockquote><p>I think Felix (the contest judge) made a bad judgement, because the winning program was not nearly as confusing as mine&#8212;it was actually very simple. If you fixed the indentation, it was quite straightforward. My program is difficult to understand even if you fix it up with good formatting and reasonable variable names. In the solution file I provided, I expanded it in this way, and it still took me about 2500 words to explain what was going on.</p></blockquote><p>He does provide a more straightened version of the code as a solution to figuring out exactly what the program does and when.  He may provide a cleaner, more organized view of the code, but trying to understand the program is left to you.  Here it is:</p><div
class="codecolorer-container perl twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table
cellspacing="0" cellpadding="0"><tbody><tr><td
style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br
/>2<br
/>3<br
/>4<br
/>5<br
/>6<br
/>7<br
/>8<br
/>9<br
/>10<br
/>11<br
/>12<br
/>13<br
/>14<br
/>15<br
/>16<br
/>17<br
/>18<br
/>19<br
/>20<br
/>21<br
/>22<br
/>23<br
/>24<br
/>25<br
/>26<br
/>27<br
/>28<br
/>29<br
/>30<br
/></div></td><td><div
class="perl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp;<span
style="color: #cc66cc;">1</span>&nbsp; <span
style="color: #0000ff;">@STATE</span> <span
style="color: #339933;">=</span> <span
style="color: #000066;">split</span> <span
style="color: #339933;">//,</span> <span
style="color: #ff0000;">&quot;.URRUUxR&quot;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp;<span
style="color: #cc66cc;">2</span>&nbsp; <span
style="color: #0000ff;">@data</span> <span
style="color: #339933;">=</span> <span
style="color: #000066;">split</span><span
style="color: #339933;">//,</span><span
style="color: #ff0000;">&quot;<span
style="color: #000099; font-weight: bold;">\n</span>rekcah xinU / lreP rehtona tsuJ&quot;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp;<span
style="color: #cc66cc;">3</span>&nbsp; <br
/> &nbsp; &nbsp; &nbsp;<span
style="color: #cc66cc;">4</span>&nbsp; <span
style="color: #000000; font-weight: bold;">sub</span> make_pipe_and_fork <span
style="color: #009900;">&#123;</span><br
/> &nbsp; &nbsp; &nbsp;<span
style="color: #cc66cc;">5</span>&nbsp; &nbsp; <span
style="color: #0000ff;">@pipestate</span><span
style="color: #009900;">&#123;</span><span
style="color: #ff0000;">&quot;r$fhno&quot;</span><span
style="color: #339933;">,</span> <span
style="color: #ff0000;">&quot;u$fhno&quot;</span><span
style="color: #009900;">&#125;</span><span
style="color: #339933;">=</span><span
style="color: #009900;">&#40;</span>P<span
style="color: #339933;">,</span>P<span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp;<span
style="color: #cc66cc;">6</span>&nbsp; &nbsp; <span
style="color: #000066;">pipe</span> <span
style="color: #ff0000;">&quot;r$fhno&quot;</span><span
style="color: #339933;">,</span> <span
style="color: #ff0000;">&quot;u$fhno&quot;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp;<span
style="color: #cc66cc;">7</span>&nbsp; &nbsp; <span
style="color: #339933;">++</span><span
style="color: #0000ff;">$fhno</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp;<span
style="color: #cc66cc;">8</span>&nbsp; &nbsp; <span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$pid</span> <span
style="color: #339933;">*=</span> <span
style="color: #cc66cc;">2</span><span
style="color: #009900;">&#41;</span> <span
style="color: #339933;">+=</span> <span
style="color: #0000ff;">$is_child</span> <span
style="color: #339933;">=</span> <span
style="color: #339933;">!</span><span
style="color: #000066;">fork</span><span
style="color: #009900;">&#40;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; &nbsp;<span
style="color: #cc66cc;">9</span>&nbsp; &nbsp; <span
style="color: #000066;">map</span> <span
style="color: #009900;">&#123;</span><br
/> &nbsp; &nbsp; <span
style="color: #cc66cc;">10</span>&nbsp; &nbsp; &nbsp; <span
style="color: #0000ff;">$STATE</span><span
style="color: #339933;">=</span><span
style="color: #0000ff;">$STATE</span><span
style="color: #009900;">&#91;</span><span
style="color: #0000ff;">$is_child</span> <span
style="color: #339933;">^</span> <span
style="color: #000066;">ord</span><span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">$pipestate</span><span
style="color: #009900;">&#123;</span><span
style="color: #0000ff;">$_</span><span
style="color: #009900;">&#125;</span><span
style="color: #009900;">&#41;</span> <span
style="color: #339933;">&amp;</span> <span
style="color: #cc66cc;">6</span><span
style="color: #009900;">&#93;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; <span
style="color: #cc66cc;">11</span>&nbsp; &nbsp; &nbsp; <span
style="color: #0000ff;">$pipestate</span><span
style="color: #009900;">&#123;</span><span
style="color: #0000ff;">$_</span><span
style="color: #009900;">&#125;</span> <span
style="color: #339933;">=</span> <span
style="color: #009900;">&#40;</span><span
style="color: #009966; font-style: italic;">/^$STATE/i</span> <span
style="color: #339933;">?</span> <span
style="color: #0000ff;">$STATE</span> <span
style="color: #339933;">:</span> <span
style="color: #000066;">close</span> <span
style="color: #0000ff;">$_</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; <span
style="color: #cc66cc;">12</span>&nbsp; &nbsp; <span
style="color: #009900;">&#125;</span> <span
style="color: #000066;">keys</span> <span
style="color: #0000ff;">%pipestate</span><br
/> &nbsp; &nbsp; <span
style="color: #cc66cc;">13</span>&nbsp; <span
style="color: #009900;">&#125;</span><br
/> &nbsp; &nbsp; <span
style="color: #cc66cc;">14</span>&nbsp; make_pipe_and_fork<span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; <span
style="color: #cc66cc;">15</span>&nbsp; make_pipe_and_fork<span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; <span
style="color: #cc66cc;">16</span>&nbsp; make_pipe_and_fork<span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; <span
style="color: #cc66cc;">17</span>&nbsp; make_pipe_and_fork<span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; <span
style="color: #cc66cc;">18</span>&nbsp; make_pipe_and_fork<span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; <span
style="color: #cc66cc;">19</span>&nbsp; <br
/> &nbsp; &nbsp; <span
style="color: #cc66cc;">20</span>&nbsp; <span
style="color: #000066;">map</span> <span
style="color: #009900;">&#123;</span><br
/> &nbsp; &nbsp; <span
style="color: #cc66cc;">21</span>&nbsp; &nbsp; <span
style="color: #0000ff;">$pipestate</span><span
style="color: #009900;">&#123;</span><span
style="color: #0000ff;">$_</span><span
style="color: #009900;">&#125;</span> <span
style="color: #339933;">=~</span> <span
style="color: #009966; font-style: italic;">/^[P.]/</span> <span
style="color: #339933;">&amp;&amp;</span> <span
style="color: #000066;">close</span> <span
style="color: #0000ff;">$_</span><br
/> &nbsp; &nbsp; <span
style="color: #cc66cc;">22</span>&nbsp; <span
style="color: #009900;">&#125;</span> <span
style="color: #0000ff;">%pipestate</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; <span
style="color: #cc66cc;">23</span>&nbsp; <br
/> &nbsp; &nbsp; <span
style="color: #cc66cc;">24</span>&nbsp; <span
style="color: #000066;">wait</span> <span
style="color: #b1b100;">until</span> <span
style="color: #0000ff;">$?</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; <span
style="color: #cc66cc;">25</span>&nbsp; <br
/> &nbsp; &nbsp; <span
style="color: #cc66cc;">26</span>&nbsp; <span
style="color: #000066;">map</span> <span
style="color: #009900;">&#123;</span> <span
style="color: #009966; font-style: italic;">/^r/</span> <span
style="color: #339933;">?</span> <span
style="color: #0000ff;">&amp;lt</span><span
style="color: #339933;">;</span> <span
style="color: #0000ff;">$_</span><span
style="color: #0000ff;">&amp;gt</span><span
style="color: #339933;">;</span> <span
style="color: #339933;">:</span> <span
style="color: #cc66cc;">1</span> <span
style="color: #009900;">&#125;</span> <span
style="color: #0000ff;">%pipestate</span><span
style="color: #339933;">;</span> <br
/> &nbsp; &nbsp; <span
style="color: #cc66cc;">27</span>&nbsp; <br
/> &nbsp; &nbsp; <span
style="color: #cc66cc;">28</span>&nbsp; <span
style="color: #0000ff;">$_</span> <span
style="color: #339933;">=</span> <span
style="color: #0000ff;">$data</span><span
style="color: #009900;">&#91;</span><span
style="color: #0000ff;">$pid</span><span
style="color: #009900;">&#93;</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; <span
style="color: #cc66cc;">29</span>&nbsp; <span
style="color: #000066;">sleep</span> <span
style="color: #000066;">rand</span><span
style="color: #009900;">&#40;</span><span
style="color: #cc66cc;">2</span><span
style="color: #009900;">&#41;</span> <span
style="color: #b1b100;">if</span> <span
style="color: #009966; font-style: italic;">/\S/</span><span
style="color: #339933;">;</span><br
/> &nbsp; &nbsp; <span
style="color: #cc66cc;">30</span>&nbsp; <span
style="color: #000066;">print</span></div></td></tr></tbody></table></div><p>Not bad.  Not bad at all.</p> ]]></content:encoded> <wfw:commentRss>http://pthree.org/2005/09/30/perl-camel-code/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced) (user agent is rejected)

Served from: pthree.org @ 2010-09-03 00:12:21 -->