<?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>javier arturo rodríguez &#187; Perl</title>
	<atom:link href="http://javier.rodriguez.org.mx/index.php/category/code/perl/feed" rel="self" type="application/rss+xml" />
	<link>http://javier.rodriguez.org.mx</link>
	<description>random musings</description>
	<lastBuildDate>Thu, 16 Apr 2009 14:00:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Whitespace Matters</title>
		<link>http://javier.rodriguez.org.mx/index.php/2007/08/31/whitespace-matters</link>
		<comments>http://javier.rodriguez.org.mx/index.php/2007/08/31/whitespace-matters#comments</comments>
		<pubDate>Fri, 31 Aug 2007 15:19:13 +0000</pubDate>
		<dc:creator>javier</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://javier.rodriguez.org.mx/index.php/2007/08/31/whitespace-matters/</guid>
		<description><![CDATA[Mark Jason Dominus just released SuperPython 0.91, &#8220;a Perl source filter for the SuperPython language, allowing SuperPython code to be embedded into Perl programs&#8221;.
In terms of language, it goes way beyond python itself to give proper semantics to whitespace. For instance, here is the Hello World program written in SuperPython:
#!/usr/bin/perl
use SuperPython;
Ain&#8217;t it neat? Naturally, the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://perl.plover.com/">Mark Jason Dominus</a> just released <a href="http://search.cpan.org/~mjd/SuperPython-0.91/SuperPython.pm">SuperPython 0.91</a>, &#8220;a Perl source filter for the SuperPython language, allowing SuperPython code to be embedded into Perl programs&#8221;.<br />
In terms of language, it goes way beyond python itself to give proper semantics to whitespace. For instance, here is the Hello World program written in SuperPython:</p>
<div class="codesnip-container" >#!/usr/bin/perl<br />
use SuperPython;</div>
<p>Ain&#8217;t it neat? Naturally, the result is</p>
<div class="codesnip-container" >$ ./hello.spy<br />
Hello, world.</div>
<p>just as would be expected.<br />
If you want to try this program yourself you might be surprised to find out that copy+paste won&#8217;t work, but that&#8217;s a small price to pay in exchange or the benefits of the richness of syntax and expresiveness of the language, and anyway you may download <a href="http://javier.rodriguez.org.mx/code/hello.spy">the source code for hello.spy</a> right here.<br />
Mark is very optimist in contributing the new features of SuperPython back to python itself, and has kindly offered to work closely with the Python community to see this happen.<br />
Congrats Mark, and keep up the good work!</p>
<div class="simpletags">Tags: <a href="http://technorati.com/tag/code" rel="tag">code</a>, <a href="http://technorati.com/tag/perl" rel="tag"> perl</a>, <a href="http://technorati.com/tag/python" rel="tag"> python</a>, <a href="http://technorati.com/tag/computer+languages" rel="tag"> computer languages</a></div>
]]></content:encoded>
			<wfw:commentRss>http://javier.rodriguez.org.mx/index.php/2007/08/31/whitespace-matters/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>md5pass</title>
		<link>http://javier.rodriguez.org.mx/index.php/2006/07/02/md5pass</link>
		<comments>http://javier.rodriguez.org.mx/index.php/2006/07/02/md5pass#comments</comments>
		<pubDate>Sun, 02 Jul 2006 14:35:53 +0000</pubDate>
		<dc:creator>javier</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://javier.rodriguez.org.mx/?p=62</guid>
		<description><![CDATA[This snippet is a simple wrapper around Digest::MD5&#8217;s md5_base64() builds unsalted MD5 digests encoded in base64, very useful for LDAP management and LDIF file processing.

#!/usr/bin/perl
++$&#124;;
use Digest::MD5 qw&#40;md5_base64&#41;;
if&#40;!defined&#40;$pass=shift&#41;&#41; &#123;
&#160; &#160; &#160; &#160; print &#8220;&#62; &#8220;;
&#160; &#160; &#160; &#160; $pass=&#60;STDIN&#62;;
&#160; &#160; &#160; &#160; chomp $pass;
&#125;
print encrypted&#40;$pass&#41;.&#8220;\n&#8220;;
sub encrypted &#123;
&#160; &#160; &#160; &#160; my&#40;$passwd&#41; = @_;
&#160; &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>This snippet is a simple wrapper around <a href="http://search.cpan.org/dist/Digest-MD5/MD5.pm">Digest::MD5</a>&#8217;s md5_base64() builds unsalted MD5 digests encoded in base64, very useful for LDAP management and LDIF file processing.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="co1">#!/usr/bin/perl</span><br />
++$|;</p>
<p><span class="kw2">use</span> Digest::<span class="me2">MD5</span> <a href="http://www.perldoc.com/perl5.6/pod/func/qw.html"><span class="kw3">qw</span></a><span class="br0">&#40;</span>md5_base64<span class="br0">&#41;</span>;</p>
<p><span class="kw1">if</span><span class="br0">&#40;</span>!<a href="http://www.perldoc.com/perl5.6/pod/func/defined.html"><span class="kw3">defined</span></a><span class="br0">&#40;</span><span class="re0">$pass</span>=<a href="http://www.perldoc.com/perl5.6/pod/func/shift.html"><span class="kw3">shift</span></a><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.perldoc.com/perl5.6/pod/func/print.html"><span class="kw3">print</span></a> <span class="st0">&#8220;&gt; &#8220;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$pass</span>=<span class="re4">&lt;STDIN&gt;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.perldoc.com/perl5.6/pod/func/chomp.html"><span class="kw3">chomp</span></a> <span class="re0">$pass</span>;<br />
<span class="br0">&#125;</span><br />
<a href="http://www.perldoc.com/perl5.6/pod/func/print.html"><span class="kw3">print</span></a> encrypted<span class="br0">&#40;</span><span class="re0">$pass</span><span class="br0">&#41;</span>.<span class="st0">&#8220;<span class="es0">\n</span>&#8220;</span>;</p>
<p><span class="kw2">sub</span> encrypted <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">my</span><span class="br0">&#40;</span><span class="re0">$passwd</span><span class="br0">&#41;</span> = <span class="re0">@_</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.perldoc.com/perl5.6/pod/func/return.html"><span class="kw3">return</span></a> <span class="st0">&#8216;{md5}&#8217;</span>.md5_base64<span class="br0">&#40;</span><span class="re0">$passwd</span><span class="br0">&#41;</span>.<span class="st0">&#8216;==&#8217;</span>;<br />
<span class="br0">&#125;</span></div>
</div>
<p>(<a href="/code/md5pass.txt">Source code</a>)</p>
<p>Use it as such:</p>
<pre>$ bin/md5pass
> <b>password</b>
{md5}X03MO1qnZdYdgyfeuILPmQ==
</pre>
<div class="simpletags">Tags: <a href="http://technorati.com/tag/Perl" rel="tag">Perl</a>, <a href="http://technorati.com/tag/MD5" rel="tag"> MD5</a>, <a href="http://technorati.com/tag/code" rel="tag"> code</a>, <a href="http://technorati.com/tag/code+snippet" rel="tag"> code snippet</a></div>
]]></content:encoded>
			<wfw:commentRss>http://javier.rodriguez.org.mx/index.php/2006/07/02/md5pass/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some lovely ASCII Art</title>
		<link>http://javier.rodriguez.org.mx/index.php/2006/06/28/some-lovely-ascii-art</link>
		<comments>http://javier.rodriguez.org.mx/index.php/2006/06/28/some-lovely-ascii-art#comments</comments>
		<pubDate>Wed, 28 Jun 2006 10:54:12 +0000</pubDate>
		<dc:creator>javier</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Hack!]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://javier.rodriguez.org.mx/?p=60</guid>
		<description><![CDATA[Andrew Savige&#8217;s Bottles of Beer have been found by the Python pundits (and by some gutless Perl defectors ;-) ) and are being waved as a textbook executable-line-noise example. There&#8217;s people that can&#8217;t  stand beauty when they see it.

(That code is now an image -see below- but you can always get the original source [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.99-bottles-of-beer.net/language-perl-737.html">Andrew Savige&#8217;s Bottles of Beer</a> have been found by the Python pundits (and by <a href="http://blog.delaguardia.com.mx/">some gutless Perl defectors</a> ;-) ) and are being waved as a textbook executable-line-noise example. There&#8217;s people that can&#8217;t  stand beauty when they see it.<br />
<a href="http://javier.rodriguez.org.mx/code/bottle.txt"><img src="http://javier.rodriguez.org.mx/wp-content/uploads/2006/09/bottle.png" alt="Bottles of Beer"/></a><br />
(That code is now an image -see below- but you can always get the <a href="/code/bottle.txt">original source code</a>).<br />
Yup, it is a Perl program. Yes, it *does* run, with <a href="/code/bottle-run.txt">interesting results</a>. There&#8217;s even a CPAN module &#8212; <a href="http://search.cpan.org/dist/Acme-EyeDrops/lib/Acme/EyeDrops.pm">Acme::EyeDrops</a> &#8212; that turns your own Perl programs into purposely unmaintainable yet beautiful works of art that can make the entire Python Party cringe in disgust. You have to admit that there&#8217;s certain merit in making  grown men cry. Automatically, no less. <a href="http://search.cpan.org/dist/Acme-EyeDrops/lib/Acme/EyeDrops.pm#99_Bottles_of_Beer">Go and read how it&#8217;s done</a>.<br />
So the Obfuscated Python Contest is incredibly boring. I couldn&#8217;t care less.<br />
Via <a href="http://blog.delaguardia.com.mx/index.php?op=ViewArticle&#038;articleId=49&#038;blogId=1">Carlos de la Guardia</a>/<a href="http://marc.abramowitz.info/archives/2006/06/15/perl-is-evil/">Marc Abramowitz</a>/<a href="http://blog.amber.org/2006/06/16/why-perl-is-simply-absurdist-theatre/">Chris Petrilli<a>.<br />
<b>Update 20060916:</b> Replaced the code with a graphical version because WordPress 2.0 doesn&#8217;t play well with the text hightlight plugin.<br /><div class="simpletags">Tags: <a href="http://technorati.com/tag/Perl" rel="tag">Perl</a>, <a href="http://technorati.com/tag/Python" rel="tag"> Python</a>, <a href="http://technorati.com/tag/Obfuscation" rel="tag"> Obfuscation</a>, <a href="http://technorati.com/tag/ASCII+art" rel="tag"> ASCII art</a></div>
]]></content:encoded>
			<wfw:commentRss>http://javier.rodriguez.org.mx/index.php/2006/06/28/some-lovely-ascii-art/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Find out LDAP client IPs</title>
		<link>http://javier.rodriguez.org.mx/index.php/2006/01/23/find-out-ldap-client-ips</link>
		<comments>http://javier.rodriguez.org.mx/index.php/2006/01/23/find-out-ldap-client-ips#comments</comments>
		<pubDate>Tue, 24 Jan 2006 02:11:47 +0000</pubDate>
		<dc:creator>javier</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[SysAdmin]]></category>

		<guid isPermaLink="false">http://javier.rodriguez.org.mx/?p=50</guid>
		<description><![CDATA[ips.pl is a simple perl filter that processes SunONE Directory Server 5.2 access logs to find out the IP addresses that queries are coming from. It&#8217;s very useful to evaluate the impact for migrating LDAP infrastructures. Most comments and variable names are in spanish but the code should be clear enough to any SODS sysadmin. [...]]]></description>
			<content:encoded><![CDATA[<p>ips.pl is a simple perl filter that processes SunONE Directory Server 5.2 access logs to find out the IP addresses that queries are coming from. It&#8217;s very useful to evaluate the impact for migrating LDAP infrastructures. Most comments and variable names are in spanish but the code should be clear enough to any SODS sysadmin. Or drop me a line if you absolutely need an all-english version.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="co1">#!/usr/bin/perl</span><br />
<span class="co1"># ips.pl $Revision: 1.1 $</span><br />
<span class="co1"># Analiza archivos access de Sun ONE Directory Server 5.2 para generar</span><br />
<span class="co1"># reporte de IPs de clientes y servidores</span><br />
<span class="co1"># Copyright (C) 2005 Javier Arturo Rodriguez</span><br />
<span class="kw2">use</span> strict;<br />
<span class="kw1">my</span><span class="br0">&#40;</span><span class="re0">$acceso</span><span class="br0">&#41;</span>;<br />
<span class="kw1">my</span> <span class="re0">$filename</span> = <a href="http://www.perldoc.com/perl5.6/pod/func/shift.html"><span class="kw3">shift</span></a> <span class="re0">@ARGV</span>;<br />
<a href="http://www.perldoc.com/perl5.6/pod/func/die.html"><span class="kw3">die</span></a><span class="br0">&#40;</span><span class="st0">&#8220;Usage:<span class="es0">\t</span>$0 &lt;filename&gt;<span class="es0">\n</span><span class="es0">\t</span>bunzip2 -c &lt;filename.bz2&gt; | $0 -<span class="es0">\n</span>&#8220;</span><span class="br0">&#41;</span> <span class="kw1">unless</span> <span class="re0">$file</span><br />
name;<br />
<a href="http://www.perldoc.com/perl5.6/pod/func/open.html"><span class="kw3">open</span></a><span class="br0">&#40;</span>FILE,<span class="st0">&#8220;&lt;$filename&#8221;</span><span class="br0">&#41;</span>;<br />
<span class="kw1">while</span><span class="br0">&#40;</span><span class="re4">&lt;FILE&gt;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.perldoc.com/perl5.6/pod/func/chomp.html"><span class="kw3">chomp</span></a>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$_</span>=~<a href="http://www.perldoc.com/perl5.6/pod/func/m.html"><span class="kw3">m</span></a>,^\<span class="br0">&#91;</span><span class="br0">&#40;</span>.*?<span class="br0">&#41;</span>\<span class="br0">&#93;</span>.*?connection from <span class="br0">&#40;</span><span class="br0">&#91;</span>\d\.<span class="br0">&#93;</span>+<span class="br0">&#41;</span> to <span class="br0">&#40;</span><span class="br0">&#91;</span>\d\.<span class="br0">&#93;</span>+<span class="br0">&#41;</span>,<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$acceso</span>-&gt;<span class="br0">&#123;</span>$<span class="nu0">3</span><span class="br0">&#125;</span>-&gt;<span class="br0">&#123;</span>$<span class="nu0">2</span><span class="br0">&#125;</span>-&gt;<span class="br0">&#123;</span>TS<span class="br0">&#125;</span>=$<span class="nu0">1</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ++<span class="re0">$acceso</span>-&gt;<span class="br0">&#123;</span>$<span class="nu0">3</span><span class="br0">&#125;</span>-&gt;<span class="br0">&#123;</span>$<span class="nu0">2</span><span class="br0">&#125;</span>-&gt;<span class="br0">&#123;</span>CNT<span class="br0">&#125;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span><br />
<a href="http://www.perldoc.com/perl5.6/pod/func/close.html"><span class="kw3">close</span></a><span class="br0">&#40;</span>FILE<span class="br0">&#41;</span>;<br />
<span class="kw1">foreach</span> <span class="kw1">my</span> <span class="re0">$dst</span> <span class="br0">&#40;</span><a href="http://www.perldoc.com/perl5.6/pod/func/sort.html"><span class="kw3">sort</span></a> <a href="http://www.perldoc.com/perl5.6/pod/func/keys.html"><span class="kw3">keys</span></a> %<span class="br0">&#123;</span><span class="re0">$acceso</span>||<span class="br0">&#123;</span><span class="br0">&#125;</span><span class="br0">&#125;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.perldoc.com/perl5.6/pod/func/print.html"><span class="kw3">print</span></a> <span class="st0">&#8220;Acceden a traves de $dst<span class="es0">\n</span>&#8220;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">foreach</span> <span class="kw1">my</span> <span class="re0">$src</span> <span class="br0">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.perldoc.com/perl5.6/pod/func/reverse.html"><span class="kw3">reverse</span></a> <a href="http://www.perldoc.com/perl5.6/pod/func/sort.html"><span class="kw3">sort</span></a> <span class="br0">&#123;</span> <span class="re0">$acceso</span>-&gt;<span class="br0">&#123;</span><span class="re0">$dst</span><span class="br0">&#125;</span>-&gt;<span class="br0">&#123;</span><span class="re0">$a</span><span class="br0">&#125;</span>-&gt;<span class="br0">&#123;</span>CNT<span class="br0">&#125;</span> &lt;=&gt; <span class="re0">$acceso</span>-&gt;<span class="br0">&#123;</span><span class="re0">$dst</span><span class="br0">&#125;</span><br />
-&gt;<span class="br0">&#123;</span><span class="re0">$b</span><span class="br0">&#125;</span>-&gt;<span class="br0">&#123;</span>CNT<span class="br0">&#125;</span> <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.perldoc.com/perl5.6/pod/func/keys.html"><span class="kw3">keys</span></a> %<span class="br0">&#123;</span><span class="re0">$acceso</span>-&gt;<span class="br0">&#123;</span><span class="re0">$dst</span><span class="br0">&#125;</span>||<span class="br0">&#123;</span><span class="br0">&#125;</span><span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.perldoc.com/perl5.6/pod/func/printf.html"><span class="kw3">printf</span></a><span class="br0">&#40;</span><span class="st0">&#8220;&nbsp; %-15s (last seen on %s; %d hit%s)<span class="es0">\n</span>&#8220;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$src</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$acceso</span>-&gt;<span class="br0">&#123;</span><span class="re0">$dst</span><span class="br0">&#125;</span>-&gt;<span class="br0">&#123;</span><span class="re0">$src</span><span class="br0">&#125;</span>-&gt;<span class="br0">&#123;</span>TS<span class="br0">&#125;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$acceso</span>-&gt;<span class="br0">&#123;</span><span class="re0">$dst</span><span class="br0">&#125;</span>-&gt;<span class="br0">&#123;</span><span class="re0">$src</span><span class="br0">&#125;</span>-&gt;<span class="br0">&#123;</span>CNT<span class="br0">&#125;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$acceso</span>-&gt;<span class="br0">&#123;</span><span class="re0">$dst</span><span class="br0">&#125;</span>-&gt;<span class="br0">&#123;</span><span class="re0">$src</span><span class="br0">&#125;</span>-&gt;<span class="br0">&#123;</span>CNT<span class="br0">&#125;</span>==<span class="nu0">1</span>?<span class="st0">&#8221;</span>:<span class="st0">&#8217;s&#8217;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div>
</div>
<p>(<a href="/code/ips.txt">Download</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://javier.rodriguez.org.mx/index.php/2006/01/23/find-out-ldap-client-ips/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>countdown</title>
		<link>http://javier.rodriguez.org.mx/index.php/2005/12/30/countdown</link>
		<comments>http://javier.rodriguez.org.mx/index.php/2005/12/30/countdown#comments</comments>
		<pubDate>Fri, 30 Dec 2005 15:53:56 +0000</pubDate>
		<dc:creator>javier</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://javier.rodriguez.org.mx/?p=47</guid>
		<description><![CDATA[This small script is an alternative to sleep(1) that gives a visual clue to the user about the remaining seconds in the delay

#!/usr/bin/perl
$&#124;++;
my $secs = shift;
die&#40;&#8220;Usage: $0 &#60;secs&#62;\n&#8220;&#41; unless &#40;defined $secs&#41; &#38;&#38; &#40;$secs&#62;=0&#41;;
while&#40;$secs&#62;0&#41; &#123;
&#160; &#160; &#160; &#160; printf&#40;&#8220;\r% 4d&#8221;, $secs&#41;;
&#160; &#160; &#160; &#160; sleep 1;
&#160; &#160; &#160; &#160; &#8211;$secs;
&#125;
print &#8220;Done&#160; &#160; &#160; &#160; &#160; \n&#8220;;

(Download)
There [...]]]></description>
			<content:encoded><![CDATA[<p>This small script is an alternative to <a href="http://www.die.net/doc/linux/man/man1/sleep.1.html">sleep(1)</a> that gives a visual clue to the user about the remaining seconds in the delay</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="co1">#!/usr/bin/perl</span><br />
$|++;</p>
<p><span class="kw1">my</span> <span class="re0">$secs</span> = <a href="http://www.perldoc.com/perl5.6/pod/func/shift.html"><span class="kw3">shift</span></a>;<br />
<a href="http://www.perldoc.com/perl5.6/pod/func/die.html"><span class="kw3">die</span></a><span class="br0">&#40;</span><span class="st0">&#8220;Usage: $0 &lt;secs&gt;<span class="es0">\n</span>&#8220;</span><span class="br0">&#41;</span> <span class="kw1">unless</span> <span class="br0">&#40;</span><a href="http://www.perldoc.com/perl5.6/pod/func/defined.html"><span class="kw3">defined</span></a> <span class="re0">$secs</span><span class="br0">&#41;</span> &amp;&amp; <span class="br0">&#40;</span><span class="re0">$secs</span>&gt;=<span class="nu0">0</span><span class="br0">&#41;</span>;<br />
<span class="kw1">while</span><span class="br0">&#40;</span><span class="re0">$secs</span>&gt;<span class="nu0">0</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.perldoc.com/perl5.6/pod/func/printf.html"><span class="kw3">printf</span></a><span class="br0">&#40;</span><span class="st0">&#8220;<span class="es0">\r</span>% 4d&#8221;</span>, <span class="re0">$secs</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.perldoc.com/perl5.6/pod/func/sleep.html"><span class="kw3">sleep</span></a> <span class="nu0">1</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &#8211;<span class="re0">$secs</span>;<br />
<span class="br0">&#125;</span><br />
<a href="http://www.perldoc.com/perl5.6/pod/func/print.html"><span class="kw3">print</span></a> <span class="st0">&#8220;Done&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="es0">\n</span>&#8220;</span>;</div>
</div>
<p>(<a href="/code/countdown.txt">Download</a>)<br />
There are numerous instances where you might want your shell scripts to sleep(1) giving the user a clue about what&#8217;s going on, but just to relate to a <a href="/index.php/2005/12/28/count/">previous example</a>, let&#8217;s see how this can be used to throttle file leeching:</p>
<div class="codesnip-container" >$ for i in `count 1 10 %02d`; do wget http://&#8230;./file-$i.pdf; countdown 30; done</div>
]]></content:encoded>
			<wfw:commentRss>http://javier.rodriguez.org.mx/index.php/2005/12/30/countdown/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>count</title>
		<link>http://javier.rodriguez.org.mx/index.php/2005/12/28/count</link>
		<comments>http://javier.rodriguez.org.mx/index.php/2005/12/28/count#comments</comments>
		<pubDate>Wed, 28 Dec 2005 15:33:32 +0000</pubDate>
		<dc:creator>javier</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://javier.rodriguez.org.mx/?p=44</guid>
		<description><![CDATA[count is a minimalist perl script in the spirit of seq(1) but with a simpler syntax. It only counts in increments of 1, but -on the other hand- it knows how to count down.

#!/usr/bin/perl
use strict;
my&#40;$from,$to,$fmt,$inc&#41;=@ARGV;
$to&#124;&#124;=$from;
$fmt&#124;&#124;=&#8220;%d&#8221;;
print join&#40;&#8220;\n&#8220;,map&#123;sprintf&#40;&#8220;$fmt&#8221;,$_&#41;&#125;&#40;$from&#62;$to?reverse&#40;$to..$from&#41;:&#40;$from..$to&#41;&#41;&#41;,&#8220;\n&#8220;;

(Download)
For instance, &#8220;count 10 1 %03d&#8221; will count down from 10 to 0 padding with zeroes to three digits. &#8220;count [...]]]></description>
			<content:encoded><![CDATA[<p>count is a minimalist perl script in the spirit of <a href="http://www.die.net/doc/linux/man/man1/seq.1.html">seq(1)</a> but with a simpler syntax. It only counts in increments of 1, but -on the other hand- it knows how to count down.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="co1">#!/usr/bin/perl</span><br />
<span class="kw2">use</span> strict;<br />
<span class="kw1">my</span><span class="br0">&#40;</span><span class="re0">$from</span>,<span class="re0">$to</span>,<span class="re0">$fmt</span>,<span class="re0">$inc</span><span class="br0">&#41;</span>=<span class="re0">@ARGV</span>;<br />
<span class="re0">$to</span>||=<span class="re0">$from</span>;<br />
<span class="re0">$fmt</span>||=<span class="st0">&#8220;%d&#8221;</span>;<br />
<a href="http://www.perldoc.com/perl5.6/pod/func/print.html"><span class="kw3">print</span></a> <a href="http://www.perldoc.com/perl5.6/pod/func/join.html"><span class="kw3">join</span></a><span class="br0">&#40;</span><span class="st0">&#8220;<span class="es0">\n</span>&#8220;</span>,<a href="http://www.perldoc.com/perl5.6/pod/func/map.html"><span class="kw3">map</span></a><span class="br0">&#123;</span><a href="http://www.perldoc.com/perl5.6/pod/func/sprintf.html"><span class="kw3">sprintf</span></a><span class="br0">&#40;</span><span class="st0">&#8220;$fmt&#8221;</span>,<span class="re0">$_</span><span class="br0">&#41;</span><span class="br0">&#125;</span><span class="br0">&#40;</span><span class="re0">$from</span>&gt;<span class="re0">$to</span>?<a href="http://www.perldoc.com/perl5.6/pod/func/reverse.html"><span class="kw3">reverse</span></a><span class="br0">&#40;</span><span class="re0">$to</span>..<span class="re0">$from</span><span class="br0">&#41;</span>:<span class="br0">&#40;</span><span class="re0">$from</span>..<span class="re0">$to</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>,<span class="st0">&#8220;<span class="es0">\n</span>&#8220;</span>;</div>
</div>
<p>(<a href="/code/count.txt">Download</a>)<br />
For instance, &#8220;count 10 1 %03d&#8221; will count down from 10 to 0 padding with zeroes to three digits. &#8220;count 0 15 %x&#8221; will count in hex. If you omit the <a href="http://perldoc.perl.org/functions/sprintf.html">format string</a> it will default to &#8220;%d&#8221; (decimal, no padding).<br />
count is very useful -among other things- for file leeching:</p>
<div class="codesnip-container" >$ for i in `count 1 10 %02d`; do wget http://&#8230;./file-$i.pdf; done</div>
]]></content:encoded>
			<wfw:commentRss>http://javier.rodriguez.org.mx/index.php/2005/12/28/count/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>de64</title>
		<link>http://javier.rodriguez.org.mx/index.php/2005/12/27/de64</link>
		<comments>http://javier.rodriguez.org.mx/index.php/2005/12/27/de64#comments</comments>
		<pubDate>Tue, 27 Dec 2005 16:00:08 +0000</pubDate>
		<dc:creator>javier</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://javier.rodriguez.org.mx/?p=43</guid>
		<description><![CDATA[Base64 is used to encode binary data in printable ASCII form. de64 is a trivial perl script to decode such strings:

#!/usr/bin/perl
use MIME::Base64;
local $/ = undef;
print decode_base64&#40;shift&#124;&#124;&#60;STDIN&#62;&#41;;

(Download)
One application of de64 is decoding UTF8 LDAP attributes inside LDIF files. For instance, &#8220;cn:: Um9iZXJ0byBNYXJ0w61uZXo=&#8221; may be decoded with
$ de64 Um9iZXJ0byBNYXJ0w61uZXo=
Roberto Martí­nez
(Look Randal! I&#8217;m using a CPAN module this [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Base64">Base64</a> is used to encode binary data in printable ASCII form. de64 is a trivial perl script to decode such strings:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="co1">#!/usr/bin/perl</span><br />
<span class="kw2">use</span> MIME::<span class="me2">Base64</span>;<br />
<a href="http://www.perldoc.com/perl5.6/pod/func/local.html"><span class="kw3">local</span></a> $/ = <a href="http://www.perldoc.com/perl5.6/pod/func/undef.html"><span class="kw3">undef</span></a>;<br />
<a href="http://www.perldoc.com/perl5.6/pod/func/print.html"><span class="kw3">print</span></a> decode_base64<span class="br0">&#40;</span>shift||<span class="re4">&lt;STDIN&gt;</span><span class="br0">&#41;</span>;</div>
</div>
<p>(<a href="/code/de64.txt">Download</a>)<br />
One application of de64 is decoding UTF8 LDAP attributes inside LDIF files. For instance, &#8220;cn:: Um9iZXJ0byBNYXJ0w61uZXo=&#8221; may be decoded with</p>
<div class="codesnip-container" >$ de64 Um9iZXJ0byBNYXJ0w61uZXo=<br />
Roberto Martí­nez</div>
<p>(Look Randal! I&#8217;m using a CPAN module this time! ;-) ) Of course, all the heavy lifting is done by <a href="http://perldoc.perl.org/MIME/Base64.html">MIME::Base64</a> from <a href="http://www.cpan.org/">CPAN</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://javier.rodriguez.org.mx/index.php/2005/12/27/de64/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>perlwhich</title>
		<link>http://javier.rodriguez.org.mx/index.php/2005/12/24/perlwhich</link>
		<comments>http://javier.rodriguez.org.mx/index.php/2005/12/24/perlwhich#comments</comments>
		<pubDate>Sat, 24 Dec 2005 18:51:30 +0000</pubDate>
		<dc:creator>javier</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://javier.rodriguez.org.mx/?p=41</guid>
		<description><![CDATA[Are you wondering where the heck does some arcane module come from? Wonder no more, perlwhich comes to the rescue:

#!/usr/bin/perl
use strict;
use File::Spec;
my $module = shift @ARGV;
$module=~s,\.,,igs;
my $pm=$module.&#8216;.pm&#8217;;
my @path = split&#40;/::/,$pm&#41;;
my $found = 0;
foreach my $dir &#40;@INC&#41; &#123;
&#160; &#160; &#160; &#160; my $file = File::Spec-&#62;catfile&#40;$dir,@path&#41;;
&#160; &#160; &#160; &#160; if&#40;-f $file&#41; &#123;
&#160; &#160; &#160; &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>Are you wondering where the heck does some arcane module come from? Wonder no more, perlwhich comes to the rescue:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="co1">#!/usr/bin/perl</span><br />
<span class="kw2">use</span> strict;<br />
<span class="kw2">use</span> File::<span class="me2">Spec</span>;</p>
<p><span class="kw1">my</span> <span class="re0">$module</span> = <a href="http://www.perldoc.com/perl5.6/pod/func/shift.html"><span class="kw3">shift</span></a> <span class="re0">@ARGV</span>;<br />
<span class="re0">$module</span>=~<a href="http://www.perldoc.com/perl5.6/pod/func/s.html"><span class="kw3">s</span></a>,\.,,igs;<br />
<span class="kw1">my</span> <span class="re0">$pm</span>=<span class="re0">$module</span>.<span class="st0">&#8216;.pm&#8217;</span>;<br />
<span class="kw1">my</span> <span class="re0">@path</span> = <a href="http://www.perldoc.com/perl5.6/pod/func/split.html"><span class="kw3">split</span></a><span class="br0">&#40;</span>/::/,<span class="re0">$pm</span><span class="br0">&#41;</span>;<br />
<span class="kw1">my</span> <span class="re0">$found</span> = <span class="nu0">0</span>;<br />
<span class="kw1">foreach</span> <span class="kw1">my</span> <span class="re0">$dir</span> <span class="br0">&#40;</span><span class="re0">@INC</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">my</span> <span class="re0">$file</span> = File::<span class="me2">Spec</span>-&gt;<span class="me1">catfile</span><span class="br0">&#40;</span><span class="re0">$dir</span>,<span class="re0">@path</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>-f <span class="re0">$file</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.perldoc.com/perl5.6/pod/func/print.html"><span class="kw3">print</span></a> <span class="re0">$file</span>,<span class="st0">&#8220;<span class="es0">\n</span>&#8220;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$found</span>=<span class="nu0">1</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span><br />
<a href="http://www.perldoc.com/perl5.6/pod/func/exit.html"><span class="kw3">exit</span></a><span class="br0">&#40;</span>!<span class="re0">$found</span><span class="br0">&#41;</span>;</div>
</div>
<p>(<a href="/code/perlwhich.txt">Download</a>)<br />
Next time you need to know some module&#8217;s path just run it like this:</p>
<div class="codesnip-container" >$ perlwhich Data::Dumper<br />
/usr/lib/perl/5.8/Data/Dumper.pm</div>
<p>If a module resides in multiple locations under @INC, perlwhich will let you know as well:</p>
<div class="codesnip-container" >$ perlwhich Salesforce<br />
/usr/local/lib/site_perl/Salesforce.pm<br />
/usr/local/share/perl/5.8.4/Salesforce.pm</div>
]]></content:encoded>
			<wfw:commentRss>http://javier.rodriguez.org.mx/index.php/2005/12/24/perlwhich/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Luhn algorithm in Perl</title>
		<link>http://javier.rodriguez.org.mx/index.php/2005/12/23/luhn-algorithm-in-perl</link>
		<comments>http://javier.rodriguez.org.mx/index.php/2005/12/23/luhn-algorithm-in-perl#comments</comments>
		<pubDate>Fri, 23 Dec 2005 12:54:36 +0000</pubDate>
		<dc:creator>javier</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://javier.rodriguez.org.mx/?p=40</guid>
		<description><![CDATA[Here&#8217;s an implementation of the Luhn algorithm in perl.

#!/usr/bin/perl
use strict;
my $number = shift&#40;@ARGV&#41; &#124;&#124; die&#40;&#8220;Usage: $0 &#60;number&#62;\n&#8220;&#41;;
$number=~s,&#91;^0-9&#93;,,g;
my&#40;$sum,$odd&#41;;
foreach my $n &#40;split&#40;//,$number&#41;&#41; &#123;
&#160; &#160; &#160; &#160; $odd=!$odd;
&#160; &#160; &#160; &#160; if&#40;$odd&#41; &#123;
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; $sum+=$n;
&#160; &#160; &#160; &#160; &#125; else &#123;
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; my $x=2*$n;
&#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s an implementation of the <a href="http://en.wikipedia.org/wiki/Luhn_algorithm">Luhn algorithm</a> in perl.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="co1">#!/usr/bin/perl</span><br />
<span class="kw2">use</span> strict;<br />
<span class="kw1">my</span> <span class="re0">$number</span> = <a href="http://www.perldoc.com/perl5.6/pod/func/shift.html"><span class="kw3">shift</span></a><span class="br0">&#40;</span><span class="re0">@ARGV</span><span class="br0">&#41;</span> || <a href="http://www.perldoc.com/perl5.6/pod/func/die.html"><span class="kw3">die</span></a><span class="br0">&#40;</span><span class="st0">&#8220;Usage: $0 &lt;number&gt;<span class="es0">\n</span>&#8220;</span><span class="br0">&#41;</span>;<br />
<span class="re0">$number</span>=~<a href="http://www.perldoc.com/perl5.6/pod/func/s.html"><span class="kw3">s</span></a>,<span class="br0">&#91;</span>^<span class="nu0">0</span>-<span class="nu0">9</span><span class="br0">&#93;</span>,,g;<br />
<span class="kw1">my</span><span class="br0">&#40;</span><span class="re0">$sum</span>,<span class="re0">$odd</span><span class="br0">&#41;</span>;<br />
<span class="kw1">foreach</span> <span class="kw1">my</span> <span class="re0">$n</span> <span class="br0">&#40;</span><a href="http://www.perldoc.com/perl5.6/pod/func/split.html"><span class="kw3">split</span></a><span class="br0">&#40;</span>//,<span class="re0">$number</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$odd</span>=!<span class="re0">$odd</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$odd</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$sum</span>+=<span class="re0">$n</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">my</span> <span class="re0">$x</span>=<span class="nu0">2</span>*<span class="re0">$n</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$sum</span>+=<span class="re0">$x</span>&gt;<span class="nu0">9</span>?<span class="re0">$x</span>-<span class="nu0">9</span>:<span class="re0">$x</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span><br />
<span class="kw1">my</span> <span class="re0">$ok</span> = <span class="nu0">0</span>+<span class="br0">&#40;</span><span class="br0">&#40;</span><span class="re0">$sum</span>%<span class="nu0">10</span><span class="br0">&#41;</span>==<span class="nu0">0</span><span class="br0">&#41;</span>;<br />
<a href="http://www.perldoc.com/perl5.6/pod/func/exit.html"><span class="kw3">exit</span></a><span class="br0">&#40;</span><span class="br0">&#40;</span><span class="re0">$sum</span>%<span class="nu0">10</span><span class="br0">&#41;</span>!=<span class="nu0">0</span><span class="br0">&#41;</span>;</div>
</div>
<p>(<a href="/code/luhn.txt">Download</a>)</p>
<p>This program was designed for shell scripting, using something like</p>
<div class="codesnip-container" >$ if ./luhn 457623486; then echo &#8220;ok&#8221;; else echo &#8220;error&#8221;; fi<br />
ok</div>
<p>but it should be trivial to modify it for other purposes.<br />
I&#8217;m using this algorithm to validate GSM IMEI numbers, but the Luhn algorithm is also behind credit card numbers.</p>
]]></content:encoded>
			<wfw:commentRss>http://javier.rodriguez.org.mx/index.php/2005/12/23/luhn-algorithm-in-perl/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Phonetize</title>
		<link>http://javier.rodriguez.org.mx/index.php/2005/12/21/phonetize</link>
		<comments>http://javier.rodriguez.org.mx/index.php/2005/12/21/phonetize#comments</comments>
		<pubDate>Wed, 21 Dec 2005 19:52:44 +0000</pubDate>
		<dc:creator>javier</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://javier.rodriguez.org.mx/?p=39</guid>
		<description><![CDATA[A small filter to phonetize STDIN into the NATO phonetic alphabet. It&#8217;s very useful to spell passwords over the phone.

#!/usr/bin/perl
use strict;
my %ALPHA = map &#123;uc&#40;substr&#40;$_,0,1&#41;&#41;=&#62;$_&#125; qw&#40; Alpha Bravo Charlie Delta Echo Foxtrot Golf Hotel India Juliett Kilo Lima Mike November Oscar Papa Quebec Romeo Sierra Tango Uniform Victor Whiskey X-ray Yankee Zulu &#41;;
while&#40;&#60;STDIN&#62;&#41; &#123;
&#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>A small filter to phonetize STDIN into the <a href="http://en.wikipedia.org/wiki/Nato_phonetic_alphabet">NATO phonetic alphabet</a>. It&#8217;s very useful to spell passwords over the phone.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="co1">#!/usr/bin/perl</span><br />
<span class="kw2">use</span> strict;<br />
<span class="kw1">my</span> <span class="re0">%ALPHA</span> = <a href="http://www.perldoc.com/perl5.6/pod/func/map.html"><span class="kw3">map</span></a> <span class="br0">&#123;</span><a href="http://www.perldoc.com/perl5.6/pod/func/uc.html"><span class="kw3">uc</span></a><span class="br0">&#40;</span><a href="http://www.perldoc.com/perl5.6/pod/func/substr.html"><span class="kw3">substr</span></a><span class="br0">&#40;</span><span class="re0">$_</span>,<span class="nu0">0</span>,<span class="nu0">1</span><span class="br0">&#41;</span><span class="br0">&#41;</span>=&gt;<span class="re0">$_</span><span class="br0">&#125;</span> <a href="http://www.perldoc.com/perl5.6/pod/func/qw.html"><span class="kw3">qw</span></a><span class="br0">&#40;</span> Alpha Bravo Charlie Delta Echo Foxtrot Golf Hotel India Juliett Kilo Lima Mike November Oscar Papa Quebec Romeo Sierra Tango Uniform Victor Whiskey X-ray Yankee Zulu <span class="br0">&#41;</span>;<br />
<span class="kw1">while</span><span class="br0">&#40;</span><span class="re4">&lt;STDIN&gt;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.perldoc.com/perl5.6/pod/func/chomp.html"><span class="kw3">chomp</span></a>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.perldoc.com/perl5.6/pod/func/print.html"><span class="kw3">print</span></a> <span class="re0">$_</span>, <span class="st0">&#8220;<span class="es0">\n</span>&#8220;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.perldoc.com/perl5.6/pod/func/print.html"><span class="kw3">print</span></a> <a href="http://www.perldoc.com/perl5.6/pod/func/join.html"><span class="kw3">join</span></a><span class="br0">&#40;</span><span class="st0">&#8216; &#8216;</span>,<a href="http://www.perldoc.com/perl5.6/pod/func/map.html"><span class="kw3">map</span></a> <span class="br0">&#123;</span><span class="re0">$ALPHA</span><span class="br0">&#123;</span><a href="http://www.perldoc.com/perl5.6/pod/func/uc.html"><span class="kw3">uc</span></a><span class="br0">&#40;</span><span class="re0">$_</span><span class="br0">&#41;</span><span class="br0">&#125;</span>||<span class="re0">$_</span><span class="br0">&#125;</span> <span class="br0">&#40;</span><a href="http://www.perldoc.com/perl5.6/pod/func/split.html"><span class="kw3">split</span></a><span class="br0">&#40;</span>//,<span class="re0">$_</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>,<span class="st0">&#8220;<span class="es0">\n</span>&#8220;</span>;<br />
<span class="br0">&#125;</span></div>
</div>
<p>Here&#8217;s the <a href="/code/phonetize.txt">source code</a>.<br />
Yup, I know about <a href="http://search.cpan.org/~jfitz/Lingua-Alphabet-Phonetic-Password-0.11/lib/Lingua/Alphabet/Phonetic/Password.pm">Lingua::Alphabet::Phonetic::NATO</a> but I needed a quick script without module dependencies. Yes, I haven&#8217;t been able to learn the NATO phonetic alphabet yet -unlike some geeks with too much time in their hands (you know who you are)-  and yes, I know I&#8217;m lazy, but that&#8217;s why I am a perl fan anyway ;-) .<br />
There&#8217;s more information about <a href="http://en.wikipedia.org/wiki/Nato_phonetic_alphabet">this alphabet</a> at<a href="http://www.wikipedia.org/">Wikipedia</a>. You migth want to <a href="http://wikimediafoundation.org/wiki/Fundraising#Donation_methods">donate a few bucks</a> while you&#8217;re there.</p>
]]></content:encoded>
			<wfw:commentRss>http://javier.rodriguez.org.mx/index.php/2005/12/21/phonetize/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
