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.
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:
#!/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->connect($DSN,$usr,$pwd);
my $ST=$DB->prepare(<<EOSQL);
select MID, DBA, LastName, FirstName
from customers
where balance_due > 100
EOSQL
$ST->execute;
# Create a new workbook and worksheet
my $xWB = Spreadsheet::WriteExcel->new('MySpreadsheet.xls');
my $xWS = $xWB->add_worksheet("Results");
# Add column headers (use column headers from query results)
my $R=0; my $C=0;
$xWS->write($R, $C++, $_) for @{$ST->{NAME}};
# Read the query results and write them into the spreadsheet
while (my $ar=$ST->fetchrow_arrayref) {
++$R; $C=0;
$xWS->write($R, $C++, $_) for @$ar;
}
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.
...roboticus
When your only tool is a hammer, all problems look like your thumb.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.