Ten Modules I Wouldn't Go
Anywhere Without
Simon Cozens
NetThink Open Source Consultancy

(page 2)
----
Here's my personal Top 10...
(page 3)
----
Bundle::CPAN
(page 4)
----
Bundle::CPAN
MD5
use Digest::MD5 qw(md5_hex);
print md5_hex($data);
(page 5)
----
Bundle::CPAN
Compress::Zlib
use Compress::Zlib;
$fh = gzopen($filename, $mode);
$bytesread = $fh->gzreadline($line);
$byteswritten = $fh->gzwrite($buffer);
(page 6)
----
Bundle::CPAN
Archive::Tar
use Archive::Tar;
Archive::Tar->create_archive ("my.tar.gz", 9,
"/this/file", "/that/file");
$tar = Archive::Tar->new();
$tar->add_files("file/foo.c", "file/bar.c");
$tar->write("files.tar");
(page 7)
----
Bundle::CPAN
Bundle::libnet
Net::FTP RFC959 File Transfer Protocol
Net::SMTP RFC821 Simple Mail Transfer Protocol
Net::Time RFC867 Daytime Protocol
Net::Time RFC868 Time Protocol
Net::NNTP RFC977 Network News Transfer Protocol
Net::POP3 RFC1939 Post Office Protocol 3
Net::SNPP RFC1861 Simple Network Pager Protocol
(page 8)
----
Bundle::CPAN
Term::Read*
use Term::ReadLine;
$term = new Term::ReadLine 'Simple Perl calc';
$prompt = "Enter your arithmetic expression: ";
$OUT = $term->OUT || STDOUT;
while ( defined ($_ = $term->readline($prompt)) ) {
$res = eval($_), "\n";
warn $@ if $@;
print $OUT $res, "\n" unless $@;
$term->addhistory($_) if /\S/;
}
(page 9)
----
Bundle::CPAN
CPAN
riot-act:/home/simon# perl -MCPAN -e shell
cpan shell -- CPAN exploration and modules installation (v1.59_54)
ReadLine support available (try 'install Bundle::CPAN')
cpan> install Some::Module
perl -MCPAN -e 'install Some::Module'
(page 10)
----
Bundle::LWP
$page = get("http://www.netthink.co.uk");
getstore($url, $file);
head($url)
mirror($url, $file);
(page 11)
----
Mail::Send
use Mail::Send;
$msg = new Mail::Send
Subject=> "Some subject",
To => "simon@netthink.co.uk";
$msg->add("X-Mailer:", "Mail::Send");
$fh = $msg->open;
print $fh "Hello!\n";
$fh->close; # Sent!
(page 12)
----
MLDBM
use MLDBM qw(DB_File);
tie %hash, "MLDBM", "persistent" or die $!;
$hash{"foo"} = [1, 2, 3, 4];
(page 13)
----
Date::Calc
(page 14)
----
DBI
use DBI; use DBD::Mysql;
my $dbh = DBI->connect(":dbi:mysql:somedatabase", $user, $pw) || ...;
my $sth = $dbh->prepare("SELECT * FROM foo WHERE name IS NOT NULL");
$sth->execute;
my $matches = $sth->rows();
print "$matches matches found\n";
print "@row\n" while @row = $sth->fetchrow_array;
(page 15)
----
Data::Dumper
use Data::Dumper;
print "State of hash:\n", Dumper($href);
(page 16)
----
POE
"POE is an application kernel that uses event driven state machines as
threads. It includes a high-level I/O library that hides most of the
usual client/server tediosity."
(page 17)
----
File::Spec
use File::Spec::Functions;
sub which {
my $program = shift;
for (path()) {
my $test = catfile($_, $program);
return $test if -e $test and -x $test;
}
}
(page 18)
----
XML::Simple
use XML::Simple;
$hashref = XMLin($filename);
print FILE XMLout($filename);
(page 19)
----
And more...
Parse::RecDescent
Mail::Internet
Mail::Audit
File::Temp (core)
...
(page 20)