Use Perl on Pi supercomputer

Configure CPAN (Comprehensive Perl Archive Network) on Pi

Load GCC and Perl modules

$ module load gcc perl

Create a local dir for Perl modules

$ mkdir -p ~/.perl/modules

Run CPAN configuration

$ export http_proxy=http://proxy.pi.sjtu.edu.cn:3004/; export https_proxy=http://proxy.pi.sjtu.edu.cn:3004/
$ module purge; module load gcc perl
$ cpan
...
cpan> o conf mbuildpl_arg "--install_base ~/.perl/modules"
cpan> o conf makepl_arg "PREFIX=~/.perl/modules"
cpan> o conf commit
cpan> exit

Add CPAN settings to .bash_profile

Add the following settings to your .bash_profile:

PATH="$HOME/perl5/bin${PATH:+:${PATH}}"
export PATH
PERL5LIB="$HOME/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}":$HOME/.perl/modules
export PERL5LIB
PERL_LOCAL_LIB_ROOT="$HOME/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"
export PERL_LOCAL_LIB_ROOT
PERL_MB_OPT="--install_base \"$HOME/perl5\""
export PERL_MB_OPT
PERL_MM_OPT="INSTALL_BASE=$HOME/perl5"
export PERL_MM_OPT

Log out then in to make the settings take effects.

Install Perl modules in CPAN

Synosys

$ export http_proxy=http://proxy.pi.sjtu.edu.cn:3004/; export https_proxy=http://proxy.pi.sjtu.edu.cn:3004/
$ module load gcc perl
$ cpan
cpan> install MODULE_NAME

Examples

$ export http_proxy=http://proxy.pi.sjtu.edu.cn:3004/; export https_proxy=http://proxy.pi.sjtu.edu.cn:3004/    
$ module load gcc perl
$ cpan
cpan> install XML::LibXML
...
cpan> install Getopt::Std
...
cpan> install Encode

A SLURM job sample for Perl

Usage: sbatch job.slurm

#!/bin/bash

#SBATCH -J Perl
#SBATCH -p cpu
#SBATCH --mail-type=end
#SBATCH --mail-user=YOU@EMAIL.COM
#SBATCH -o %j.out
#SBATCH -e %j.err
#SBATCH -n 1

source /usr/share/Modules/init/bash
unset MODULEPATH
module use /lustre/usr/modulefiles/pi
module purge
module load gcc perl

perl hello.pl

Reference