<!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-&gt;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-&gt;expand(&quot;Module&quot;,&quot;/./&quot;)){</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; next unless $mod-&gt;inst_file;</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; next if $mod-&gt;uptodate;</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; printf &quot;Module %s is installed as %s, could be updated to %s from CPAN\n&quot;,</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $mod-&gt;id, $mod-&gt;inst_version, $mod-&gt;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-&gt;install(CPAN::Shell-&gt;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&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Direct: 913.403.5261</FONT>
<BR><FONT SIZE=2>5828 Reeds Road&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Main: 913.384.1008</FONT>
<BR><FONT SIZE=2>Mission, KS 66202&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Fax: 913.384.2180</FONT>
<BR><FONT SIZE=2>www.scriptpro.com&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; garrett at scriptpro dot com</FONT>
</P>
<BR>

</BODY>
</HTML>