How to upgrade perl modules that install from CPAN?

# cpan
cpan> h

Display Information                                                (ver 1.9800)
 command  argument          description
 a,b,d,m  WORD or /REGEXP/  about authors, bundles, distributions, modules
 i        WORD or /REGEXP/  about any of the above
 ls       AUTHOR or GLOB    about files in the author's directory
    (with WORD being a module, bundle or author name or a distribution
    name of the form AUTHOR/DISTRIBUTION)

Download, Test, Make, Install...
 get      download                     clean    make clean
 make     make (implies get)           look     open subshell in dist directory
 test     make test (implies make)     readme   display these README files
 install  make install (implies test)  perldoc  display POD documentation

Upgrade
 r        WORDs or /REGEXP/ or NONE    report updates for some/matching/all modules
 upgrade  WORDs or /REGEXP/ or NONE    upgrade some/matching/all modules

Pragmas
 force  CMD    try hard to do command  fforce CMD    try harder
 notest CMD    skip testing

Other
 h,?           display this menu       ! perl-code   eval a perl command
 o conf [opt]  set and query options   q             quit the cpan shell
 reload cpan   load CPAN.pm again      reload index  load newer indices
 autobundle    Snapshot                recent        latest CPAN uploads

Running just the below command will do what you ask.

cpan> upgrade

$ cpan Module

and

cpan> install Module 

will upgrade if a newer version is available, and do nothing if you already have the latest version.


I suggest you using cpanm "family" script for perl modules management.

Install cpanm

  • skip this, if you already have it
  • curl -L http://cpanmin.us | perl - --sudo App::cpanminus
  • if you're on freebsd you can use instead curl the command fetch (see: man fetch)

Upgrade cpanm

  • skip this, if you installed it right now
  • cpanm --self-upgrade --sudo

Install cpan-outdated

  • cpanm App::cpanoutdated
  • The cpan-outdated command do the same as CPAN (r), but IMO better to use from shell

For example, only my notebook gives the result like:

marvin:~ jomo$ cpan-outdated
S/SM/SMUELLER/Attribute-Handlers-0.93.tar.gz
D/DR/DROLSKY/Class-Load-0.20.tar.gz
D/DR/DROLSKY/DateTime-TimeZone-1.47.tar.gz
... etc

Run cpan-outdated & upgrade modules

  • cpan-outdated -p | cpanm

Changes

If you want see what is changed (Change-log), you can try install cpan-listchanges

  • cpanm App::cpanlistchanges
  • and use it like: cpan-listchanges Plack - too see what's changed in Plack between your local and the latest on CPAN

Tags:

Perl

Cpan

Upgrade