cpanm, the easy installer for Perl modules

I've become totally addicted to cpanm, the easy installer for Perl modules. It's not yet in Slackware, and not on slackbuilds.org either, but (as root) ridiculously easy to install with:

curl -L http://cpanmin.us | perl - App::cpanminus

You just say something like cpanm LWP::Simple and and all the dependencies will be resolved. I just installed thirty modules with six commands (most were dependencies) and cpanm did all the work. Sometimes upgrading is not so bad.

I did have one problem with an old module that I had installed in a separate folder to mirror the file structure of a host provider I use. Looks scary (I hate undefined symbols!) but in this case easy to resolve. The error in apache's error_log looks something like this:

/srv/username/lib/i486-linux-thread-multi/auto/Unicode/LineBreak/LineBreak.so: undefined symbol: Perl_Gthr_key_ptr, referer: http://localhost/~username/script.cgi

The reason was simply that I had compiled Unicode::LineBreak on my old system, so I had to remove and reinstall (of course cpanm compiles it when necessary).

update Sun Apr 27 09:32:35 CEST 2014

cpanm is supposed to be without dependencies, but in Slackware 14.1 it complained about List::Util not being up to date.

List::Util version 1.33 required--this is only version 1.27 at /usr/local/bin/cpanm line 189.

This forced me to first upgrade that module in the old way by hand:

  1. Download (from cpan.org) the package.
  2. untar the package with tar zxvf Scalar-List*z
  3. perl Makefile.PL
  4. cd into the new folder
  5. make
  6. make test (to check for errors)
  7. su; make install

update Wednesday 21 May 2014

For the one line command with curl, obviously you need curl to be installed, which may not be the case in a basic Ubuntu server install. You may also need to install make and clang. Alternatively you can install cpanm with apt-get, but the package is called cpanminus:

apt-get install cpanminus