I've been landed with the job of documenting how to install a very complicated application onto a clean server. Part of the application requires a lot of perl scripts, each of which seem to require lots of different perl modules.

I don't know much about perl, and I only know one way to install the required modules. This means my documentation now looks this:

Type each of these commands and accept all the defaults:

sudo perl -MCPAN -e 'install JSON'
sudo perl -MCPAN -e 'install Date::Simple'
sudo perl -MCPAN -e 'install Log::Log4perl'
sudo perl -MCPAN -e 'install Email::Simple'
(.... continues for 2 more pages... )

Is there any way I can do all this one line like I can with aptitude i.e.

Type the following command and go get a coffee:

sudo aptitude install openssh-server libapache2-mod-perl2 build-essential ...

Thank you (on behalf of the long suffering people who will be reading my document)

EDIT: The best way to do this is to use the packaged versions. For the modules which were not packaged for Ubuntu 10.10 I ended up with a little perl script which I found here )

#!/usr/bin/perl -w
    use CPANPLUS;
    use strict;
    CPANPLUS::Backend->new( conf => { prereqs => 1 } )->install(
        modules => [ qw(
        ) ]

This means I can put a nice one liner in my document:

sudo perl installmodules.pl

Depending on your distribution, many perl modules may be already packaged.

Before using CPAN check if some/most/all of the needed packages are not already available for your distro.

  • Brilliant, I've tried that for several of the modules and most are packaged for Ubuntu 10.10. Thanks! – Colin Pickard Feb 22 '11 at 16:31
  • I found this to be a good way of finding packages: yinfor.com/blog/archives/2007/04/… – Colin Pickard Feb 22 '11 at 16:32
  • 1
    @Colin, the names are completely deterministic, per Debian policy. Email::Simple becomes libemail-simple-perl. – Tobu Feb 26 '11 at 21:23
  • @Tobu Useful to know, this will let me check for those modules I've still not got packages for. Thank you. – Colin Pickard Mar 1 '11 at 10:09

I have found CPAN less than ideal for long running systems as updating modules over time seems to be less than ideal.

I would recommend using your system's built in package management system instead. By using a distribution specific repository you should have fewer issues with dependencies, and as modules get updated you will receive the new versions as well. Since you appear to be using Ubuntu, you may need to enable some of the extra repositories such as world, or metaverse, or uber-ultra-intraverse.

Failing this, there is a relatively new website called Linux Packages Search that attempts to compile packages for all manner of systems. I have had good luck with finding any extra packages that I needed on it, if it wasn't available anywhere else.


If you need to do a from-source install of these modules (as I often need to, since I install them as a non-root user in a location other than the system standard) I recommend CPANPLUS as a worthwhile upgrade to standard CPAN - it handles dependency resolution and can automatically install all a module's dependencies while you get a coffee.

Also, if this big complicated application you're installing is also distributed on the CPAN (I'm going to make an outside guess that it's RT, everybody's favourite perl dependency nightmare), there's often a Bundle::AppName package on the CPAN as well which rolls up everything needed for a given version of the app.

Hope that helps; good luck!

  • +1 CPANPLUS is what I used for those modules that were not packaged for Ubuntu 10.10, thank you! – Colin Pickard Feb 24 '11 at 8:48

I'd create a Task style module that bundles all your dependency listings into a CPAN style module. That way you can use standard cpan tools to manage it. For example, here's a bundle I often use (shameless plug)


You could probably just take something like that and modify as needed.

Additionally consider using local::lib rather than the global perl include path. That way you get better management of your deps, and you don't need root. Here's a link to a good, free book that covers this (amongst other things)



use system function and use && operator after each module installation like

system("sudo apt-get install 1 && sudo apt-get install 2 &&....");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.