Helping ordinary people create extraordinary websites!
GET OUR NEWSLETTER
Your Email:
 

Automate Perl Module Deployment

By Martin C. Brown
2005-04-27


Automating CPAN

Most people are familiar with CPAN as an interactive shell for building and installing Perl modules. What many don't realize is that the CPAN module that provides this functionality is actually just a wrapper around an internal application program interface (API). For example, to generate a list of installed modules that are out of date compared with the versions available on CPAN, you can simply call CPAN::Shell->r. Listing 1 provides an example of the command and its output.

Listing 1. Code to generate a list of outdated modules

$ perl -MCPAN -e 'CPAN::Shell->r'

CPAN: Storable loaded ok
Going to read /export/build/solaris/cpan/Metadata
Database was generated on Sun, 25 Jul 2004 02:10:00 GMT

Package namespace installed latest in CPAN file
B::Assembler 0.06 0.07 N/NW/NWCLARK/perl-5.8.5.tar.gz
Cwd 2.19 2.20 K/KW/KWILLIAMS/Cwd-2.20.tar.gz
DBD::mysql 2.9003 2.9004 R/RU/RUDY/DBD-mysql-2.9004.tar.gz
DateTime 0.2101 0.22 D/DR/DROLSKY/DateTime-0.22.tar.gz
DateTime::TimeZone 0.27 0.28 D/DR/DROLSKY/DateTime-TimeZone-0.28.tar.gz
File::Scan 1.23 1.25 H/HD/HDIAS/File-Scan-1.25.tar.gz
File::Spec 0.87 0.88 K/KW/KWILLIAMS/File-Spec-0.88.tar.gz
Image::Magick 5.5.7 6.0 J/JC/JCRISTY/PerlMagick-6.02.tar.gz
Mail::ClamAV 0.08 0.11 S/SA/SABECK/Mail-ClamAV-0.11.tar.gz
Module::CoreList 1.94 1.95 R/RC/RCLAMP/Module-CoreList-1.95.tar.gz
POE 0.2802 0.29 R/RC/RCAPUTO/POE-0.29.tar.gz
XML::RSS::Parser 2.11 2.15 T/TI/TIMA/XML-RSS-Parser-2.15.tar.gz
htmlop v0.2.6 0.26 J/JA/JANL/w3mir-1.0.10.tar.gz
5 installed modules have a version number of 0
890 installed modules have no parseable version number
To install these modules automatically so that you are up to date, embed the call to CPAN::Shell->r in a call to the CPAN::Shell->install function:
$ /usr/local/bin/perl -MCPAN -e 'CPAN::Shell->install(CPAN::Shell->r)'

This code dumps the information you see in Listing 1, then installs each module to bring it up to date.

Tutorial Pages:
» Scripts go Beyond CPAN to Ease Network Installations
» Perl Module Installation
» Automating CPAN
» Automating CPAN Across a Network
» Use CPAN to Create a Rigid Installation
» Conclusions
» Resources


First published by IBM DeveloperWorks


 | Bookmark
Related Tutorials:
» Random subroutines in Perl
» Log Script Use
» Creating Perl Modules for Web Sites
» Bit Vector, Using Perl Vec
» Build a Perl/CGI Voting System
» Perl Range Operator

Advertise with Us!


Tutorials Scripts Web Hosting Developer Manuals
Resources