Debian Perl FAQ

Perl is used quite extensively in Debian. Not only are some core functions written in Perl, but there many packages in Debian that have perl in their name.

Dpkg, Perl and CPAN

Searching the Comprehensive Perl Archive Network (CPAN) can be as much of a candy-store experience as searching the Debian packages for software. CPAN provides a way for Perl developers to distribute their work in an organized fashion that includes user feedback.

Before you take the plunge and run perl -MCPAN -e shell, consider what the effects of your actions will be on your nice dpkg system. Installing directly from CPAN into usr/lib/perl will mean you are mixing dpkg managed files with CPAN managed files, and most likely the dependencies of dpkg will never be the same.

The way Debian's Perl package in Sarge is configured CPAN works just fine. The Debian Perl package defines siteprefix as /usr/local and sitelib as /usr/local/share/perl/5.8.4 and sitearch as /usr/local/lib/perl/5.8.4. Because of this if you use CPAN and take the default settings your extra stuff from CPAN goes into the right places in /usr/local.

From CPAN distribution to Debian package: dh-make-perl

Enter dh-make-perl. This debhelper program handles the Debianizing process of Perl modules from CPAN.

dh-make-perl --build --cpan Perl::Tidy

This will make a Debian package in the current directory for installing the Perl::Tidy module. Installing the package will update the dpkg database and keep your package dependencies in order:

As root, run something like:

sudo dpkg -i libperl-tidy_xxxx.deb

You will still need to use discretion when choosing packages to build and install. For example, while you could use dh-make-perl to build CGI::Kwiki, a DebianDeveloper is already maintaining this package ( Kwiki ) and is most likely doing a better job than this automated build will do. Plus the bug tracking system (BTS) is in place.

If the module isn't available for your release or isn't available at all, dh-make-perl away.

Feel free to see for best practices on how to debianize perl modules.

per-user Perl modules

If you don't have system install privileges, or if you don't need to make site-wide installs of the perl modules, you could use CPAN and install into ~/perl.

The documentation has this advice for using CPAN into ~/perl:

When the CPAN module is installed, a site wide configuration file is created as CPAN/ The default values defined there can be overridden in another configuration file: CPAN/!? You can store this file in $HOME/.cpan/CPAN/!? if you want, because $HOME/.cpan is added to the search path of the CPAN module before the use() or require() statements.

5) I am not root, how can I install a module in a personal directory?

You will most probably like something like this:

  o conf makepl_arg "LIB=~/myperl/lib \
                    ["INSTALLMAN1DIR"]=~/myperl/man/man1 \
  install Sybase::Sybperl

You can make this setting permanent like all o conf settings with o conf commit.

You will have to add ~/myperl/man to the MANPATH environment variable and also tell your perl programs to look into ~/myperl/lib, e.g. by including

use lib "$ENV{HOME}/myperl/lib";

or setting the ?PERL5LIB environment variable.

Another thing you should bear in mind is that the UNINST parameter should never be set if you are not root.

Running a different version of Perl in usr/local

What about installing into usr/local?

This should work similarly to the tips on running out of $HOME, with the advantage of possibly already having /usr/local/lib/perl/<version> in your @INC. Look for /usr/lib/*/ to see how your /usr/bin/perl is configured.

What if you want to install an updated version of perl in usr/local for experimental work but keep the Debian/Release version in usr?

This setup may not work out well with the Debian Perl package for Sarge since it has its own ideas about Perl stuff in /usr/local.

How can I make my @INC path more dynamic

If you have your Perl module (.pm) files in the same directory or same relative directory from your Perl program files (aka scripts ) then ?FindBin may be the package for you.

If you want to not force a directory structure depenancy on your program and libs but you aren't using /usr/lib/perl for your libs, try these tricks:

Program reads a config file in the same directory using open()

  my $l = <CONF>;
  chomp($l); #remove trailing LF
  require lib;

-- config --

Program requires a local config script.

   require "";

-- --
# Local setting overrides for program
use lib qw( /my/libs/path );
# You can define a uselib package and some
# variables to export here

Communicating about Perl on Debian

Please see Debian Perl Group for ways of interacting about anything perl in Debian.

Perl package Spotlight


This impressively effective email scoring tool uses Perl's regexp power to its fullest. It also allows other programs to be plugged into it, increasing its flexibility and power. SpamAssassin

Kwiki (of course)

A Quickie Wiki that's not too Tricky.