Solution: Perl modules needing updates

Garrett Goebel garrett at scriptpro.com
Mon Nov 14 10:48:06 CST 2005


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...


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):

# list all installed modules that have newer version on CPAN
perl -e 'use CPAN; CPAN::Shell->r;'

Which is nice from the command-line, but prints a lot of extraneous info.


So here's the script they list that you could save off and run via a cron
job:

# list all modules on my disk that have newer versions on CPAN
for $mod (CPAN::Shell->expand("Module","/./")){
    next unless $mod->inst_file;
    next if $mod->uptodate;
    printf "Module %s is installed as %s, could be updated to %s from
CPAN\n",
           $mod->id, $mod->inst_version, $mod->cpan_version;
}


And here's how you could update everything to the current recommendations
from the command-line:

# install everything that is outdated on my disk:
perl -MCPAN -e 'CPAN::Shell->install(CPAN::Shell->r)'

cheers,

Garrett

--
Garrett Goebel
IS Development Specialist

ScriptPro                   Direct: 913.403.5261
5828 Reeds Road               Main: 913.384.1008
Mission, KS 66202              Fax: 913.384.2180
www.scriptpro.com          garrett at scriptpro dot com


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://kclug.org/pipermail/kclug/attachments/20051114/01ae5a89/attachment.htm


More information about the Kclug mailing list