<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">

<channel>
<title>Hackszine: Perl</title>
<link>http://www.hackszine.com/blog/archive/perl/</link>
<description>O&apos;Reilly&apos;s Hacks Series reclaims the term &apos;hacking&apos; for the good guys--innovators who explore and experiment, unearth shortcuts, create useful tools, and come up with fun things to try on their own</description>
<language>en-us</language>
<copyright>Copyright 2008, O'Reilly Media, Inc.</copyright>
<lastBuildDate>Thu, 23 Oct 2008 19:53:54 -0800</lastBuildDate>
<pubDate>Fri, 14 Nov 2008 08:56:52 -0800</pubDate>
<generator>http://www.movabletype.org/?v=4.1</generator>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<itunes:author>O'Reilly Media, Inc.</itunes:author>
<itunes:subtitle>Clever solutions to interesting problems.</itunes:subtitle>
<itunes:summary>Hackszine Podcast</itunes:summary>
<itunes:owner>
<itunes:email>webmaster@makezine.com</itunes:email>
</itunes:owner>
<category>Technology</category>
<itunes:category text="Technology">
</itunes:category>
<itunes:category text="Technology">
  <itunes:category text="Gadgets" />
</itunes:category>
<itunes:category text="Games &amp; Hobbies" >
</itunes:category>
<itunes:category text="Science">
</itunes:category>
<itunes:image href="http://makezine.com/images/hackszine/rss_icon.jpg" />
<itunes:explicit>no</itunes:explicit>


<item>
<title>Simple stock quote grabbing with Perl</title>
<itunes:summary>Hackszine reader 3riador wrote in to recommend a quick and easy way to grab stock quotes using Perl and the Finance::Quote CPAN module. The codebase is actively maintained and has been around for some time, having first been distributed as...</itunes:summary>
<description>
<![CDATA[<p>Hackszine reader 3riador wrote in to recommend a quick and easy way to grab stock quotes using Perl and the Finance::Quote CPAN module. The codebase is actively maintained and has been around for some time, having first been distributed as part of GNUCash before becoming its own project.</p>

<p>Paul Fenwick, one of the GNUCash developers, had this to say in an article for The Perl Journal in 2000:</p>

<blockquote>If you have a reason to watch the world's financial markets, and you know a little about perl, then you may find that the Finance::Quote package comes in handy. I personally use it to remind myself that I should never buy shares, as I have a good history of losing money on the stock exchange.  However, you can use Finance::Quote to help track those tasty stock options you've been offered, or even to help you build dynamic artwork driven by fluctuations in the world markets.</blockquote>

<p>Near as I can tell, the dynamic artwork that's referred to is the Stock Puppets presentation which was shown at 2000s Burning Man event (can anyone confirm this?). The idea was to have large marionettes controlled directly by stock market data, some servos, Basic Stamp microcontrollers, and IBM Thinkpads pulling market data using the Finance::Quote library.</p>

<p>To use Finance::Quote in your own projects is a simple task. Here's a few lines of code that will print the current price of Google shares:</p>

<blockquote>
#!/usr/bin/perl -w

<p>use strict;<br />
use Finance::Quote;</p>

<p><br />
my $q = Finance::Quote->new();<br />
my %data = $q->fetch('usa', 'GOOG');<br />
print $data{'GOOG', 'price'} . "\n";<br />
</blockquote></p>

<p>The Dabbler Blog has more information on installation and basic usage, and The Perl Journal article is a good resource for those wishing to delve any deeper.</p>

<p><a href="http://finance-quote.sourceforge.net/index.html">Finance::Quote Perl Library</a><br />
<a href="http://sethjust.wordpress.com/2008/10/23/fast-and-simple-stock-quotes-using-perl/">Dabbler Blog - Fast and Simple Stock Quotes Using Perl</a><br />
<a href="http://finance-quote.sourceforge.net/tpj/finance-quote.txt">Finance::Quote Article In The Perl Journal</a><br />
<a href="http://www.stockpuppets.com/howto-overview.html">Stock Puppets</a></p>]]>
[&lt;a href="http://www.hackszine.com/blog/archive/2008/10/simple_stock_quote_grabbing_wit.html?CMP=OTC-7G2N43923558" /&gt;Read More&lt;/a&gt;]  
[&lt;a href="http://www.hackszine.com/blog/archive/2008/10/simple_stock_quote_grabbing_wit.html?CMP=OTC-7G2N43923558#comments" /&gt;Comments&lt;/a&gt;]
</description>
<link>http://www.hackszine.com/blog/archive/2008/10/simple_stock_quote_grabbing_wit.html?CMP=OTC-7G2N43923558</link>
<guid>http://www.hackszine.com/blog/archive/2008/10/simple_stock_quote_grabbing_wit.html?CMP=OTC-7G2N43923558</guid>
<category>Perl</category>
<pubDate>Thu, 23 Oct 2008 19:53:54 -0800</pubDate>

</item>

<item>
<title>Read Excel files in Perl and PHP</title>
<itunes:summary>Relational databases that speak SQL are the data-storage backbone for most developers. Unfortunately, but most of the data that&apos;s created outside the control of the technology caste at a typical workplace is in Excel format. Because of this, being able...</itunes:summary>
<description>
<![CDATA[<p>Relational databases that speak SQL are the data-storage backbone for most developers.  Unfortunately, but most of the data that's created outside the control of the technology caste at a typical workplace is in Excel format. Because of this, being able to procedurally read and write Excel documents with a familiar language can open up a whole world of possibilities for automation and data migration.</p>

<p>Assuming you're attempting to read and write standard text (Ie. not binary/graphic) data from Excel worksheets, this is actually fairly doable in PHP and Perl.</p>

<p>A recent article by Mike Diehl at Linux Journal peaked my interest in this. He shows off some of the features of the Spreadsheet::ParseExcel Perl module, which can be used to pull data and even formatting information from cells in an Excel worksheet.  Once you have your hands on the data, you can do what you want with it: output it to XML, toss it in a database for subsequent querying, or even convert it into other Excel documents (oh, the shame).</p>

<p><b>Perl Excel Libraries and Information</b><br />
<a href="http://search.cpan.org/~szabgab/Spreadsheet-ParseExcel-0.32/lib/Spreadsheet/ParseExcel.pm">Spreadsheet:ParseExcel - Read from Excel 95/97/2000 documents</a><br />
<a href="http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel-2.24/lib/Spreadsheet/WriteExcel.pm">Spreadsheet:WriteExcel - Write to Excel 97/2000/2002/2003 documents</a><br />
<a href="http://www.linuxjournal.com/content/reading-native-excel-files-perl">Linux Journal - Reading Native Excel Files in Perl</a></p>

<p>There are libraries for dealing with native Excel files in PHP as well. The following two seem to be the only options for binary Excel documents.</p>

<p><b>PHP Excel Libraries</b><br />
<a href="http://sourceforge.net/projects/phpexcelreader/">PHP Excel_Reader - Read Excel 95 and 97 documents</a><br />
<a href="http://pear.php.net/package/Spreadsheet_Excel_Writer">Spreadsheet_Excel_Writer - Write Excel 5.0 documents</a><br />
<a href="http://devzone.zend.com/article/3336-Reading-and-Writing-Spreadsheets-with-php">Reading and Writing Spreadsheets with PHP</a></p>

<p>With the most recent version of Excel, there is an XML file format option that will allow you to read and write data in a worksheet by directly interacting with the saved file's DOM. IBM has a document that details doing this with PHP, and it would be straightforward to apply this technique to Perl as well.</p>

<p><a href="http://www.ibm.com/developerworks/xml/library/os-phpexcel/index.html">Read/Write XML Excel Data in PHP</a></p>

<p>Finally, if all you need to do is output a document that can be read in Excel, a standard CSV-format file will usually do the trick. Escaping can be a bit tricky, however, and my preferred format has become a plain-old HTML table. Just create a file that contains a TABLE element (no BODY or HTML tags necessary), with any number of TR rows and html-escaped data in the TDs, and save it out.  If you use the XLS file extension, it will open directly in Excel with a double-click and Excel never seems to mind reading in the data.</p>

<p>Do you have any other Excel programming hacks?  Give us a shout in the comments.</p>]]>
[&lt;a href="http://www.hackszine.com/blog/archive/2008/09/read_excel_files_in_perl_and_p.html?CMP=OTC-7G2N43923558" /&gt;Read More&lt;/a&gt;]  
[&lt;a href="http://www.hackszine.com/blog/archive/2008/09/read_excel_files_in_perl_and_p.html?CMP=OTC-7G2N43923558#comments" /&gt;Comments&lt;/a&gt;]
</description>
<link>http://www.hackszine.com/blog/archive/2008/09/read_excel_files_in_perl_and_p.html?CMP=OTC-7G2N43923558</link>
<guid>http://www.hackszine.com/blog/archive/2008/09/read_excel_files_in_perl_and_p.html?CMP=OTC-7G2N43923558</guid>
<category>Excel</category>
<pubDate>Fri, 05 Sep 2008 20:23:43 -0800</pubDate>

</item>

<item>
<title>Change the message on HP printers</title>
<itunes:summary> A lesser-known feature of the HP Printer Job Language (HPPJL) command set is that you can change the ready message&quot; from &quot;READY&quot; to whatever you like. Yaakov wrote a Perl script that will change the message for you, and...</itunes:summary>
<description>
<![CDATA[<p><img alt="hpinsertcoin_20071018.jpg" src="http://hackszine.com/hpinsertcoin_20071018.jpg" width="500" height="447" /></p>

<p>A lesser-known feature of the HP Printer Job Language (HPPJL) command set is that you can change the ready message" from "READY" to whatever you like.  Yaakov wrote a Perl script that will change the message for you, and he also came up with the clever "INSERT COIN" replacement. Very nice.</p>

<blockquote>You can think up your own funny, confusing or scary messages. My personal favorite is "INSERT COIN" which fits perfectly on the small LCDs. You can even sit in sight of the printer and change the message while watching the reaction of your victim. Don't be surprised, though, if a large fraction don't even notice. I was quite surprised myself but, it appears, some people don't look at what is in front of them.</blockquote>

<p>I haven't been able to test yet (no HP printer here), but if I'm reading the code right, you can actually do this right from the command line using telnet.  Just telnet to port 9100 and type in the following:</p>

<pre>
\e%-12345X\@PJL JOB
\@PJL RDYMSG DISPLAY="MESSAGE HERE"
\@PJL EOJ
\e%-12345X
</pre>

<p>INSERT COIN: changing the "Ready Message" on HP printers - [<a href="http://www.boingboing.net/2007/10/17/howto-change-the-pri.html">via</a>] <a href="http://kovaya.com/miscellany/2007/10/insert-coin.html">Link</a><br />
HP LaserJet Commands (PDF) - <a href="http://www.hpinfo.cz/Data/PCL&PJL/HPPJL.pdf">Link</a></p>]]>
[&lt;a href="http://www.hackszine.com/blog/archive/2007/10/change_the_message_on_hp_print.html?CMP=OTC-7G2N43923558" /&gt;Read More&lt;/a&gt;]  
[&lt;a href="http://www.hackszine.com/blog/archive/2007/10/change_the_message_on_hp_print.html?CMP=OTC-7G2N43923558#comments" /&gt;Comments&lt;/a&gt;]
</description>
<link>http://www.hackszine.com/blog/archive/2007/10/change_the_message_on_hp_print.html?CMP=OTC-7G2N43923558</link>
<guid>http://www.hackszine.com/blog/archive/2007/10/change_the_message_on_hp_print.html?CMP=OTC-7G2N43923558</guid>
<category>Perl</category>
<pubDate>Wed, 17 Oct 2007 21:50:52 -0800</pubDate>
<enclosure url="http://www.hpinfo.cz/Data/PCL&PJL/HPPJL.pdf" length="361030" type="application/pdf" />
</item>

<item>
<title>Whistle to control your computer</title>
<itunes:summary>R2D2 was on to something. Think easier speech recognition with reduced error rates: Use Linux® or Microsoft® Windows®, the open source sndpeek program, and a simple Perl script to read specific sequences of tonal events -- literally whistling, humming, or...</itunes:summary>
<description>
<![CDATA[<p>R2D2 was on to something.  Think easier speech recognition with reduced error rates:</p>

<blockquote>Use Linux® or Microsoft® Windows®, the open source sndpeek program, and a simple Perl script to read specific sequences of tonal events -- literally whistling, humming, or singing at your computer -- and run commands based on those tones. Give your computer a short low whistle to check your e-mail or unlock your your screensaver with the opening bars of Beethoven's Fifth Symphony. Whistle while you work for higher efficiency.</blockquote>

<p>This ought to be nostalgic for all of you who remember trying to whistle a successful modem handshake sequence.  (Someone please tell me I'm not the only nerd in the room who did this for kicks.)</p>

<p>Whistle while you work to run commands on your computer - <a href="http://www-128.ibm.com/developerworks/library/os-whistle/index.html?ca=dgr-lnxw97whistlework">Link</a></p>]]>
[&lt;a href="http://www.hackszine.com/blog/archive/2007/06/whistle_to_control_your_comput.html?CMP=OTC-7G2N43923558" /&gt;Read More&lt;/a&gt;]  
[&lt;a href="http://www.hackszine.com/blog/archive/2007/06/whistle_to_control_your_comput.html?CMP=OTC-7G2N43923558#comments" /&gt;Comments&lt;/a&gt;]
</description>
<link>http://www.hackszine.com/blog/archive/2007/06/whistle_to_control_your_comput.html?CMP=OTC-7G2N43923558</link>
<guid>http://www.hackszine.com/blog/archive/2007/06/whistle_to_control_your_comput.html?CMP=OTC-7G2N43923558</guid>
<category>Linux</category>
<pubDate>Thu, 21 Jun 2007 21:49:31 -0800</pubDate>

</item>

<item>
<title>AppleTV Perl plugin</title>
<itunes:summary> Phil @ Make writes: Erica has a special treat for Perl folks with Apple TVs! On Sunday, with a hundred better things to do but no incentive to do them, I put together an Apple TV plug-in that allows...</itunes:summary>
<description>
<![CDATA[<p><img src="http://www.makezine.com/blog/PerlAppliance1.jpg" height="281" width="500" border="0" hspace="4" vspace="4" alt="Perlappliance1" /><br />
<img src="http://www.makezine.com/blog/PerlAppliance2.jpg" height="281" width="500" border="0" hspace="4" vspace="4" alt="Perlappliance2" /><br />
<img src="http://www.makezine.com/blog/PerlAppliance7.jpg" height="281" width="500" border="0" hspace="4" vspace="4" alt="Perlappliance7" /><br />
<img src="http://www.makezine.com/blog/PerlAppliance4.jpg" height="281" width="500" border="0" hspace="4" vspace="4" alt="Perlappliance4" /></p>

<p>Phil @ <a href="http://www.makezine.com/blog/archive/2007/04/appletv_perl_plugin.html">Make</a> writes: <a href="http://www.makezine.com/pub/au/Erica_Sadun">Erica</a> has a special treat for Perl folks with Apple TVs!</p>

<blockquote>On Sunday, with a hundred better things to do but no incentive to do them, I put together an Apple TV plug-in that allows you to run any Perl script you place into a folder in your home directory. (/Users/frontrow/perlbin).

<p><br>The idea is this: a lot of people know how to write Perl who don't want to learn to program Cocoa. And you can add new scripts from your normal office work computer (via ssh) but have them all available from Apple TV. You can do date &#38; time, calendars, stock quotes, weather, and so forth. Scrape web pages, subscribe to RSS feeds, whatever.</blockquote>The plug-in is here - <a href="http://www.oreillynet.com/mac/blog/images/Perl.frappliance.zip">Link (zip).</a></p>

<p><br><strong>Related:</strong><br />
<ul><li>HOW TO - Run AppleTV on a Mac mini - <a href="http://www.makezine.com/blog/archive/2007/03/how_to_run_appletv_on_a_m.html">Link.</a></li><li>AppleTV OS on a Mac mini - <a href="http://www.makezine.com/blog/archive/2007/03/appletv_os_on_a_mac_mini.html">Link.</a></li><li>AppleTV hack weekend - <a href="http://www.makezine.com/blog/archive/2007/04/appletv_hack_weekend.html">Link.</a></li></ul></p>]]>
[&lt;a href="http://www.hackszine.com/blog/archive/2007/04/appletv_perl_plugin.html?CMP=OTC-7G2N43923558" /&gt;Read More&lt;/a&gt;]  
[&lt;a href="http://www.hackszine.com/blog/archive/2007/04/appletv_perl_plugin.html?CMP=OTC-7G2N43923558#comments" /&gt;Comments&lt;/a&gt;]
</description>
<link>http://www.hackszine.com/blog/archive/2007/04/appletv_perl_plugin.html?CMP=OTC-7G2N43923558</link>
<guid>http://www.hackszine.com/blog/archive/2007/04/appletv_perl_plugin.html?CMP=OTC-7G2N43923558</guid>
<category>AppleTV</category>
<pubDate>Tue, 10 Apr 2007 06:00:34 -0800</pubDate>

</item>

<item>
<title>Translate SQL Syntax Between Databases</title>
<itunes:summary>SQL::Translator is an interesting Perl module that, among other things, can convert database table definitions to and from several DB platforms. Essentially, this could allow you to write and maintain your table definition code for a single platform, say MySQL,...</itunes:summary>
<description>
<![CDATA[<p>SQL::Translator is an interesting Perl module that, among other things, can convert database table definitions to and from several DB platforms.  Essentially, this could allow you to write and maintain your table definition code for a single platform, say MySQL, and then use Translator to output table structure into Oracle, Sybase, or PostgreSQL dialects.</p>

<p>Manipulation of data, such as SELECT, INSERT, UPDATE and DELETE are not yet supported, so you're still on your own there if you're writing platform agnostic code.  That said, this is an incredibly useful tool.  Just consider this example that Chris Dolan posted on use Perl:</p>

<blockquote>MySQL understands this syntax:

<p>create table book (<br />
  id int,<br />
  author_id int,<br />
  FOREIGN KEY fk_author_id (author_id) REFERENCES author (id)<br />
) TYPE=InnoDB;</p>

<p>but not this nicer syntax (it silently ignores the "references" clause):</p>

<p>create table book (<br />
  id int,<br />
  author_id int references author (id),<br />
) TYPE=InnoDB;</p>

<p>Perl to the rescue! I can write my schema in the latter syntax and use SQL::Translator to rewrite into the supported syntax.<br />
</blockquote></p>

<p><b>References:</b><br />
<ul><li><a href="http://use.perl.org/~ChrisDolan/journal/31813">MySQL foreign key syntax translator</a> (4 line perl script!)</li><li><a href="http://search.cpan.org/dist/SQL-Translator/">SQL::Translator on CPAN</a></li></ul></p>]]>
[&lt;a href="http://www.hackszine.com/blog/archive/2007/02/translate_sql_syntax_between_d.html?CMP=OTC-7G2N43923558" /&gt;Read More&lt;/a&gt;]  
[&lt;a href="http://www.hackszine.com/blog/archive/2007/02/translate_sql_syntax_between_d.html?CMP=OTC-7G2N43923558#comments" /&gt;Comments&lt;/a&gt;]
</description>
<link>http://www.hackszine.com/blog/archive/2007/02/translate_sql_syntax_between_d.html?CMP=OTC-7G2N43923558</link>
<guid>http://www.hackszine.com/blog/archive/2007/02/translate_sql_syntax_between_d.html?CMP=OTC-7G2N43923558</guid>
<category>Perl</category>
<pubDate>Mon, 26 Feb 2007 00:14:09 -0800</pubDate>

</item>

<item>
<title>Linux Commands You&apos;ve Never Used</title>
<itunes:summary> # lsof | grep TCP portmap 2587 rpc 4u IPv4 5544 TCP *:sunrpc (LISTEN) rpc.statd 2606 root 6u IPv4 5585 TCP *:668 (LISTEN) sshd 2788 root 3u IPv6 5991 TCP *:ssh (LISTEN) sendmail 2843 root 4u IPv4 6160 TCP...</itunes:summary>
<description>
<![CDATA[<div style="width:490px;color:#00FF00;background-color:#000000;padding-left:10px;"><pre>

# lsof | grep TCP
portmap    2587   rpc  4u   IPv4     5544  TCP *:sunrpc (LISTEN)
rpc.statd  2606  root  6u   IPv4     5585  TCP *:668 (LISTEN)
sshd       2788  root  3u   IPv6     5991  TCP *:ssh (LISTEN)
sendmail   2843  root  4u   IPv4     6160  TCP badhd:smtp (LISTEN)
vsftpd     9337  root  3u   IPv4    34949  TCP *:ftp (LISTEN)
cupsd     16459  root  0u   IPv4    41061  TCP badhd:ipp (LISTEN)

</pre></div>
<br>
Here's a short list of useful Linux shell programs, many of which you may have never known about.  I've got a new favorite shell command, lsof (shown above), which displays information on every open file handle. - <a href="http://bashcurescancer.com/10-linux-commands-youve-never-used.html">Link.</a>
<br><br>
If I could add one to the list, it'd have to be the short and sweet command line search and replace using perl:
<br>
<pre>
perl -pi -e 's/searchpattern/replacewith/g' *.html
</pre>
<br>
Do you have a favorite command line secret?  Please share it in the comments.]]>
[&lt;a href="http://www.hackszine.com/blog/archive/2007/02/linux_commands_youve_never_use.html?CMP=OTC-7G2N43923558" /&gt;Read More&lt;/a&gt;]  
[&lt;a href="http://www.hackszine.com/blog/archive/2007/02/linux_commands_youve_never_use.html?CMP=OTC-7G2N43923558#comments" /&gt;Comments&lt;/a&gt;]
</description>
<link>http://www.hackszine.com/blog/archive/2007/02/linux_commands_youve_never_use.html?CMP=OTC-7G2N43923558</link>
<guid>http://www.hackszine.com/blog/archive/2007/02/linux_commands_youve_never_use.html?CMP=OTC-7G2N43923558</guid>
<category>Linux</category>
<pubDate>Sun, 25 Feb 2007 00:30:50 -0800</pubDate>

</item>

<item>
<title>Command Line Zip for Windows</title>
<itunes:summary>Go-to Hacks author Paul Bausch shares another productivity problem he&apos;s solved for himself with a bit of hacking:Windows doesn&apos;t have a command line utility for compressing files (that I know of), and I had to come up with a way...</itunes:summary>
<description>
<![CDATA[<p>Go-to <a href="http://www.oreillynet.com/pub/au/1200">Hacks author Paul Bausch</a> shares another productivity problem he's solved for himself with a bit of hacking:<blockquote>Windows doesn't have a command line utility for compressing files (that I know of), and I had to come up with a way to automate some file transfers today. So I whipped up a tiny Perl script that will zip up a file.</blockquote>He adds that his hack works well with Windows batch files and will save him a bunch of bandwidth. If Paul's homegrown fix looks like something you could use too, <a href="http://www.onfocus.com/2007/01/3900">check out his site</a> for the code.</p>]]>
[&lt;a href="http://www.hackszine.com/blog/archive/2007/01/command_line_zip_for_windows.html?CMP=OTC-7G2N43923558" /&gt;Read More&lt;/a&gt;]  
[&lt;a href="http://www.hackszine.com/blog/archive/2007/01/command_line_zip_for_windows.html?CMP=OTC-7G2N43923558#comments" /&gt;Comments&lt;/a&gt;]
</description>
<link>http://www.hackszine.com/blog/archive/2007/01/command_line_zip_for_windows.html?CMP=OTC-7G2N43923558</link>
<guid>http://www.hackszine.com/blog/archive/2007/01/command_line_zip_for_windows.html?CMP=OTC-7G2N43923558</guid>
<category>Windows</category>
<pubDate>Fri, 05 Jan 2007 04:38:12 -0800</pubDate>

</item>


</channel>
</rss>