Local Perl Modules Install

If you can't (or don't want to) globally (using root) install some Perl Modules that you need, here is a simple "how-to work locally":

  • Edit your ~/.bash_profile (create it if you don't have one yet) and copypaste the following (this exports are ok for x86 architectures):

 

localperl=$HOME/perl5
export PERL5LIB=$localperl/lib/perl5/i486-linux-gnu-thread-multi:$localperl/lib/perl5
export PERL_LOCAL_LIB_ROOT=$localperl
export PERL_MB_OPT="--install_base $localperl"
export PERL_MM_OPT=INSTALL_BASE=$localperl
export PATH=$localperl/bin:$PATH
  • Logout from the shell and re-login to apply the new configuration
  • If you can't or don't want to logout: source (your) .bash_profile

At this point we use the installation method explained in cpan.org which consist in:

curl -L http://cpanmin.us | perl - "the_perl_module::you_want_to_install"

First of all, curl downloads the "cpanm" executable and throw it on the standard output ( -L ). Immediately after, that output is passed into perl witch grabs it ( - ) and execute it, passing "the_perl_module::you_want_to_install" as an argument.

The string "the_perl_module::you_want_to_install" must to be changed with the actual module(s) name(s) (without the quotes) you'd like to install on your home directory. They will be stored under ~/perl5

If for some reasons you prefer to have cpanm installed as well, you can first do something like:

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

and the next time you want to install a module simply do a:

cpanm "the_perl_module::you_want_to_install"