NERSCPowering Scientific Discovery Since 1974

Perl on Genepool

Using perl on genepool

The perl packages in the legacy /jgi/tools installation of perl have been ported to a modules installation of perl.  To use the new installation of perl:

genepool% module load perl

The perl module on genepool will actually load two modules: perl, and jgi-perl-packages.  It is possible to load jgi-perl-packages module separately, and to try to use the installed packages with a different perl installation.  This may be very useful in some cases, e.g. working on a non-genepool system like carver; but some of the perl packages may not work perfectly in that case.  The jgi-perl-packages module sets up the PERL5LIB environment variable to enable access to the perl packages.

In your perl scripts, the interpreter to start up should be selected from the environment, rather than loading perl from a particular path.

#!/usr/bin/env perl
use strict;
my $fh = open(....

or, if you need to turn on specific perl options, you can use:

#!perl -t
use strict;
my $fh = open(...

Note about perl taint-checking mode:

Since the perl packages are loaded in a non-default location relative to the perl executable (i.e. specified in PERL5DIR), "perl -T" should not be used - because strict taint-checking will fail with packages in the jgi-perl-packages module.  If strict taint-checking is required, a work around is to specify the PERL5DIR entries in your script with "use lib ..."

Installing perl packages in your home directory

First, load the entire perl environment:

module load perl

Next, setup cpan:

mkdir -p $HOME/.cpan/CPAN
echo '$CPAN::Config->{cpan_home}=$ENV{"HOME"} . "/.cpan";' > $HOME/.cpan/CPAN/MyConfig.pm
echo '$CPAN::Config->{makepl_arg}= ("INSTALLDIRS"=>"site", "PREFIX"=>$ENV{"HOME"}."/perl5", "INSTALL_BASE"=>$ENV{"HOME"}."/perl5");' >> $HOME/.cpan/CPAN/MyConfig.pm
echo '$CPAN::Config->{mbuild_arg}= "--install_base " . $ENV{"HOME"}."/perl5";' >> $HOME/.cpan/CPAN/MyConfig.pm


cpan won't be able to automatically adjust your dotfiles, make the following changes:

If you use bash, add the following to $HOME/.bashrc.ext:

export PERL_LOCAL_LIB_ROOT="$HOME/perl5"
export PERL_MB_OPT="--install_base $HOME/perl5"
export PERL_MM_OPT="INSTALL_BASE=$HOME/perl5"
export PERL5LIB="$HOME/perl5/lib/perl5/x86_64-linux-thread-multi:$HOME/perl5/lib/perl5:$PERL5LIB"
export PATH="$HOME/perl5/bin:$PATH"

If you use tcsh, add the following to $HOME/.tcshrc.ext:

setenv PERL_LOCAL_LIB_ROOT "$HOME/perl5"
setenv PERL_MB_OPT "--install_base $HOME/perl5"
setenv PERL_MM_OPT "INSTALL_BASE=$HOME/perl5"
setenv PERL5LIB "$HOME/perl5/lib/perl5/x86_64-linux-thread-multi:$HOME/perl5/lib/perl5:$PERL5LIB"
setenv PATH "$HOME/perl5/bin:$PATH"

Source your dotfiles (or logout and back in again and then reload the perl module again) to accept the environment changes.  Next, to install packages, use the cpan command:

genepool% cpan
Sorry, we have to rerun the configuration dialog for CPAN.pm due to
some missing parameters. Configuration will be written to
<</global/homes/d/dmj/.cpan/CPAN/MyConfig.pm>>
...
<accept defaults>
...
cpan[1]> o conf commit
cpan[2]> quit
genepool% cpan LWP::Simple # for example
...