<?xml version="1.0" encoding="windows-1252"?>
<node id="994534" title="Re^2: Get me excited about perl" created="2012-09-19 16:31:36" updated="2012-09-19 16:31:36">
<type id="11">
note</type>
<author id="533863">
roboticus</author>
<data>
<field name="doctext">
&lt;p&gt;I'll have to chime in with [temporal]:  I think that CPAN is the best initial draw.  The capabilities of the language help make it stay great.&lt;/p&gt;
&lt;p&gt;The example I usually use to "hook" people with perl is a stripped down version of my SQL_2_excel script.  The stripped down version isn't fancy, but shows how easily you can get data from a database and into a spreadsheet:&lt;/p&gt;
&lt;c&gt;
#!/usr/bin/perl
#
#   Create a spreadsheet from an SQL query.
#
use strict;
use warnings;
use DBI;
use Spreadsheet::WriteExcel;

my $DSN = shift;
my $usr = shift;
my $pwd = shift or die "Missing argument(s)!";

# Attach to database and run query
my $DB=DBI-&gt;connect($DSN,$usr,$pwd);
my $ST=$DB-&gt;prepare(&lt;&lt;EOSQL);

select MID, DBA, LastName, FirstName
from   customers
where  balance_due &gt; 100

EOSQL
$ST-&gt;execute;

# Create a new workbook and worksheet
my $xWB = Spreadsheet::WriteExcel-&gt;new('MySpreadsheet.xls');
my $xWS = $xWB-&gt;add_worksheet("Results");

# Add column headers (use column headers from query results)
my $R=0; my $C=0;
$xWS-&gt;write($R, $C++, $_) for @{$ST-&gt;{NAME}};

# Read the query results and write them into the spreadsheet
while (my $ar=$ST-&gt;fetchrow_arrayref) {
    ++$R; $C=0;
    $xWS-&gt;write($R, $C++, $_) for @$ar;
}
&lt;/c&gt;
&lt;p&gt;It doesn't have much in the way of features (no error checking to speak of, no formatting and/or null handling, etc.).  But it's easy to see what's going on and shows that you don't need much code for some basic tasks.&lt;/p&gt;
&lt;p&gt;...[roboticus]&lt;/p&gt;
&lt;p&gt;&lt;i&gt;When your only tool is a hammer, all problems look like your thumb.&lt;/i&gt;&lt;/p&gt;</field>
<field name="root_node">
994491</field>
<field name="parent_node">
994500</field>
</data>
</node>
