Sunday, May 20, 2012

Updating all outdated Perl modules

The following is probably not the kind of procedure one would follow in a well organized environment.

I, on the other hand, have a handful of computers, each of which has a bunch of perls installed. Most of those might be activated (via perlbrew once in a while. That means, I sometimes find that I need to make sure everything is up-to-date before checking a bunch of things.

Now, with ActivePerl, you get ppm, and it is pretty convenient.

But then, on the same laptop, I also have a couple of Strawberry Perl distributions, as well as perls I built from scratch using the free Microsoft compilers.

Then, we have the Mac, with the various perls installed via MacPorts, and, also, via perlbrew. Then, there are two netbooks with ArchLinux on them, the dual boot partition on my main laptop.

I think you get the picture. Nothing is mission critical. Each Perl distribution has a bunch of modules I installed using cpanm at some point.

I'd rather try to upgrade all the modules/distributions I have for one specific perl at once: If anything is messed up, I am not averse to nuking that perl and everything that came with it, and starting from scratch. It hasn't happened yet, but if it does, I doubt I'll spend more time dealing with that than I would have fiddling with all the individual environments in turn.

Most of the time, I can just type a couple of commands and leave:

$ cpanm --self-upgrade
$ cpan-outdated |cpanm

If you want to inspect the CHANGES for everything that is outdated, you can use cpan-outdated |cpan-listchanges (hat tip Daniel Lavelle who seems to be much more disciplined about the whole thing ;-)

cpan-outdated and cpan-listchanges are helpful on their own, even if you don't go the "not a care in the world" route of cpan-outdated |cpanm.


  1. Hmm, does that pipe work on Windows?

    1. Yes. It was not clear at first that the 'cpan-outdated' command depends on the App-cpanoutdated module. I prefer:

      cpan-outdated |cpanm -v

      to see where things are breaking.

  2. I deleted my earlier comment (which was made before I had a chance to wake up ;-)

    I use ActivePerl (and this PPM) as the system Perl on my Windows machine, and ppm works fine for most cases. In special cases, I can build modules from scratch using the mingw package ActiveState provides. Also, things work very well in Cygwin and MSYS bash environments.

    The perls I build using MS VisualStudio Express are only for the purpose of checking that I can build them, so, those are not updated often.

    I had just updated 3 ArchLinux machines and one Mac laptop using this method before posting, so Windows was not on my mind. I vaguely remembered doing this from cmd.exe using MS Express compilers, and my home-built perl at some point, but I wanted to make sure, so checked it with perl-5.16.0-RC2 that I built a few days ago, here is the output:

    C:\DOCUME~1\asu1\LOCALS~1\temp> cpan-outdated |cpanm
    --> Working on D/DA/DAGOLDEN/App-Cpan-1.5902.tar.gz
    Fetching ... OK
    Configuring App-Cpan-1.5902 ... OK
    Building and testing App-Cpan-1.5902 ... OK
    Successfully installed App-Cpan-1.5902
    --> Working on B/BI/BINGOS/Archive-Extract-0.60.tar.gz
    ... OK
    Configuring Archive-Extract-0.60 ... OK

    etc etc. Now, this is subject to being on my laptop, with my customizations and fixes accumulated over many years. I cannot guarantee it will work on any other system.