Install Perl Modules In Your Scratch Directory

The local::lib module can be used to install extra perl modules that are not available on the cluster by default or in a cluster wide lua module. Follow the instructions below to setup your own modules.

1. Start with Creating a Perl configuration file,

$ perl -MCPAN -e 'mkmyconfig'
CPAN::MyConfig already exists as /home/matambo/.local/share/.cpan/CPAN/MyConfig.pm.
Running configuration again...

Answer yes to the question on automatic configuration, and choose the local::lib option in the question on choice of approach:

Would you like to configure as much as possible automatically? [yes]
...
What approach do you want?  (Choose 'local::lib', 'sudo' or 'manual')
 [local::lib]
...

Next you will be offered some user environment variables that can be added to your path, answer no.

PATH="/home/username/perl5/bin${PATH:+:${PATH}}"; export PATH;
PERL5LIB="/home/username/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB;
PERL_LOCAL_LIB_ROOT="/home/username/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT;
PERL_MB_OPT="--install_base \"/home/username/perl5\""; export PERL_MB_OPT;
PERL_MM_OPT="INSTALL_BASE=/home/username/perl5"; export PERL_MM_OPT;
 
Would you like me to append that to /home/username/.bashrc now? [yes] no

where username is your login username. After you choose 'no' we will make some changes.

Configure CPAN To Install In Your Scratch Directory

Run:

perl -MCPAN -e shell

In the perl shell, run the following:

cpan[1]> o conf makepl_arg INSTALL_BASE=/home/username/scratch/cpan_modules

this will install you perl modules in /home/username/scratch/cpan_modules At the next CPAN prompt, enter:

cpan[2]> o conf commit
cpan[3]> exit

Installing Your Modules

To install a module, run the following on the shell

$ perl -MCPAN -Mlocal::lib -e 'CPAN::install(Math::Matrix)'

Using you modules

The local::lib module has to be used to search your local library when modules are loaded;

#!/usr/bin/perl
use strict;
use local::lib;
use Math::Matrix;

Adding your Perl Modules to your PATH

Add the following to your .bashrc or your shell environment, and the top of your submission script:

PATH="/home/username/scratch/cpan_modules/bin${PATH:+:${PATH}}"; export PATH;
PERL5LIB="/home/username/scratch/cpan_modules/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB;
PERL_LOCAL_LIB_ROOT="/home/username/scratch/cpan_modules${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT;
PERL_MB_OPT="--install_base \"/home/username/scratch/cpan_modules\""; export PERL_MB_OPT;
PERL_MM_OPT="INSTALL_BASE=/home/username/scratch/cpan_modules"; export PERL_MM_OPT;

Do this, and re-login before installing any perl module. Remember to replace “username” with your login username.