System setup for modern perl projects

Some helpful tips in making your perl projects more portable.

Installing perl

Don't use the system perl installed with your operating system, instead the latest stable perl via perlbrew:

curl -L | bash
perlbrew install stable

Installing modules

The App::cpanminus and local::lib provide a lot of help here. To install these with a single command under your normal system account, run the following:

wget -O- | perl - -l ~/perl5 App::cpanminus local::lib


curl -L | perl - -l ~/perl5 App::cpanminus local::lib


Don't install modules with a perl version, instead in them in a per user, project or other directory using local::lib. This allows modules to be installed without being root and different projects can use different versions of the same module if needed.

Then add to your bash profile:

echo 'eval `perl -I ~/perl5/lib/perl5 -Mlocal::lib`' >> ~/.bash_profile
echo 'export PATH=~/perl5/bin:$PATH' >> ~/.bash_profile

Activate for the current session without having to re-login:

. ~/.bash_profile

Then add the following to your scripts in order for perl to find your projects' modules:

use FindBin qw/$Bin/;
use local::lib "$Bin/../local";


The standard CPAN shell uses a fair amount of memory, this can be a problem if running from small virtual machines, use cpanminus as the standard CPAN module is overkill for just adding/removing modules.


cpanm HTML::Form::XSS


cpanm -U HTML::Form::XSS


Use Carton for application dependencies, it also ensures that the same version of modules are installed consistently with its snapshot feature.

To install:

cpanm Carton

Create an example dependency list:

echo "requires 'Acme::Time::Baby';" >> cpanfile

Install modules listed in cpanfile:

carton install


Link to meta::cpan rather than CPAN as module pages on meta::cpan do not use the module version, so less chance of broken links in the future.

Last updated: 07/02/2015