2011-03-07

Perl - How to upgrade perl modules

Now we've know how to deal with Perl modules :

How about upgrading Perl modules?

Objective :

Upgrade a single or a couple of perl modules

Example :

  1. The current version of a module :
    $ pm-uninstall -V
    App::pmuninstall v0.15
  2. Install the module again :
    $ cpanm pm-uninstall
    ! Finding pm-uninstall on cpanmetadb failed.
    --> Working on pm-uninstall
    Fetching http://search.cpan.org/CPAN/authors/id/X/XA/XAICRON/App-pmuninstall-0.16.tar.gz ... OK
    Configuring App-pmuninstall-0.16 ... OK
    Building and testing App-pmuninstall-0.16 ... OK
    Successfully installed App-pmuninstall-0.16
  3. And the module is upgraded :
    $ pm-uninstall -V
    App::pmuninstall v0.16
    (And yup, cpanm is that cool to figure out the Distribution name, cpanm rocks !!! :))

Upgrading a couple of modules is easy. But what if I've more the a couple?
We'll need a module to get the job done, easily :

Modules required :
App::cpanoutdated

Installation :
cpanm -v App::cpanoutdated

How to use :
The help from App::cpanoutdated is useful enough,
$ cpan-outdated --help
Usage:
        # print the list of distribution that contains outdated modules
        % cpan-outdated

        # print the list of outdated modules in packages
        % cpan-outdated -p

        # verbose
        % cpan-outdated --verbose

        # alternate mirrors
        % cpan-outdated --mirror file:///home/user/minicpan/

        # additional module path(same as cpanminus)
        % cpan-outdated -l extlib/
        % cpan-outdated -L extlib/

        # install with cpan
        % cpan-outdated | xargs cpan -i

        # install with cpanm
        % cpan-outdated    | cpanm
        % cpan-outdated -p | cpanm

The CPAN module App::cpanoutdated is from Tokuhiro Matsuno.

Go try it out.

Adios !!!

1 comment:

Shimshon said...

Is there some easy way to reinstall all non-core modules when Perl is updated on your system? I've been trying to figure this one out, as an upgrade will often leave XS-based modules non-functional, even if they are the latest version.