<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=US-ASCII">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2657.73">
<TITLE>Solution: Perl modules needing updates</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2>Somebody asked the question about how to run a cron job to determine which perl modules need updates a few days back. I'd intended to answer it, but apparently it made it to my bitbucket first...</FONT></P>
<BR>
<P><FONT SIZE=2>You'll have to have CPAN configured first. But from the CPAN.pm documentation (http://search.cpan.org/~andk/CPAN-1.76/lib/CPAN.pm#Programmer's_interface):</FONT></P>
<P><FONT SIZE=2># list all installed modules that have newer version on CPAN</FONT>
<BR><FONT SIZE=2>perl -e 'use CPAN; CPAN::Shell->r;'</FONT>
</P>
<P><FONT SIZE=2>Which is nice from the command-line, but prints a lot of extraneous info.</FONT>
</P>
<BR>
<P><FONT SIZE=2>So here's the script they list that you could save off and run via a cron job:</FONT>
</P>
<P><FONT SIZE=2># list all modules on my disk that have newer versions on CPAN</FONT>
<BR><FONT SIZE=2>for $mod (CPAN::Shell->expand("Module","/./")){</FONT>
<BR><FONT SIZE=2> next unless $mod->inst_file;</FONT>
<BR><FONT SIZE=2> next if $mod->uptodate;</FONT>
<BR><FONT SIZE=2> printf "Module %s is installed as %s, could be updated to %s from CPAN\n",</FONT>
<BR><FONT SIZE=2> $mod->id, $mod->inst_version, $mod->cpan_version;</FONT>
<BR><FONT SIZE=2>}</FONT>
</P>
<BR>
<P><FONT SIZE=2>And here's how you could update everything to the current recommendations from the command-line:</FONT>
</P>
<P><FONT SIZE=2># install everything that is outdated on my disk:</FONT>
<BR><FONT SIZE=2>perl -MCPAN -e 'CPAN::Shell->install(CPAN::Shell->r)'</FONT>
</P>
<P><FONT SIZE=2>cheers,</FONT>
</P>
<P><FONT SIZE=2>Garrett</FONT>
</P>
<P><FONT SIZE=2>--</FONT>
<BR><FONT SIZE=2>Garrett Goebel</FONT>
<BR><FONT SIZE=2>IS Development Specialist</FONT>
</P>
<P><FONT SIZE=2>ScriptPro Direct: 913.403.5261</FONT>
<BR><FONT SIZE=2>5828 Reeds Road Main: 913.384.1008</FONT>
<BR><FONT SIZE=2>Mission, KS 66202 Fax: 913.384.2180</FONT>
<BR><FONT SIZE=2>www.scriptpro.com garrett at scriptpro dot com</FONT>
</P>
<BR>
</BODY>
</HTML>