I'd like to know if you have a method for managing perl modules on your Debian system, with respect to the following:

  1. Installing new modules
  2. Listing of manually installed modules
  3. Checking dependencies, and uninstalling modules

I have looked at this perlmonks article for background reading: What is the best way to install CPAN modules on Debian?

I have previously installed perl modules using the CPAN module. I have also used dh-make-perl in some cases, when following instructions to build other packages that had perl dependencies.

I'd like to institute a coherent policy on my machine so I can better manage how and where the modules are installed, and reduce the chance of breaking perl on my system. I would strongly like a system where I can detect and uninstall modules that are no longer being used.


4 Answers 4


If you use apt-get and dh-make-perl for all packages, deborphan --guess-perl will find perl packages without any dependencies, which you can then remove and run it again iteratively. deborphan has a keep list which you can add the ones you're actively using to and they won't show up.

So to make this work, you'll have to uninstall all the modules you installed via CPAN and reinstall them with dh-make-perl. Manually installed modules can be detected by looking for "No available version in archive" in the ouptut of apt-show-versions libsome-module-perl.


I use apt-get to install most modules. If a module is not in one of the repository (or if I need a latter version of a module), I install that module into my home directory with cpan. This is made easier by the local::lib module. Download the tarball from CPAN, decompress it, change directory into it, and then type

perl Makefile.pl --bootstrap
make test

If any of these steps fail, ask a question here. If all of the steps succeed then type

make install

You will then need to add the following line to whatever profile file you use (e.g. ~/.profile, ~/.bash_profile, etc.):

eval $(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)

Log out and log back in (run that command in the current terminal), and then type


It should ask you if you want to auto-configure CPAN, answer yes. When it is done you should be able to install modules to a directory named ~/perl5 by saying

cpan Module::Name

The line you put in your profile sets up the PERL5LIB variable, so programs will be able to find the modules you installed. It puts the ~/perl5 directory ahead of the system directories, so if you have version 1.0 of Foo installed via apt-get and version 2.0 of Foo installed via CPAN, the CPAN version will be loaded.

  • +1. This makes WAY more sense to me than running two completely separate perl instances/installs.
    – Warren P
    Jul 23, 2010 at 14:32

Leave Debian's Perl alone and install a second Perl that you manage with cpan:


  • I like this approach, but for one issue: Some modules I install are to satisfy dependencies in other packages that I'm aiming to build and install on my machine. If I install a second Perl, won't I have to jump through hoops to make these packages see and use the 2nd Perl at runtime, while system installed packages continue to use the original install?
    – user4358
    Sep 25, 2009 at 0:36
  • No hoops at all.
    – innaM
    Sep 25, 2009 at 9:39
  • ouch. especially if any of your perl stuff touches any debian stuff.
    – Warren P
    Jul 23, 2010 at 14:31

Depending on the modules, I'm fairly sure you can use the apt-get command to install some of the more common modules.

apt-get install perl5-crypt (maybe its p5-crypt - its been a while).

It depends a lot on what modules are required though, many of them are not in the apt packages.

  • Yes, that's a problem for me because I now have a system where some modules have been installed via apt-get, some via dh-make-perl and still others via the CPAN module.
    – user4358
    Aug 22, 2009 at 13:01

Your Answer

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