Perl¶
Perl is a general-purpose, dynamic programming language that supports both procedural and object-oriented programming. It was originally developed for text manipulation, but is now used for a wider range of tasks.
Perl is available as a module on Apocrita.
Usage¶
To run the default installed version of Perl, simply load the perl
module:
module load perl
then run Perl with a script file:
perl example.pl
Installing Perl modules¶
You can use the "bootstrapping" technique to install the Perl local::lib
package from Comprehensive Perl Archive Network (CPAN), and then self-install
Perl modules into the local library.
To install local::lib
, first load a Perl module and run the following
command:
cpan -i local::lib
If this is the first time launching cpan
, follow the interactive prompts. We
do not recommend adding the proposed environment variables into your
~/.bashrc
file. Instead, once the initial CPAN setup has completed, you
can run the following command to activate your local library and set all the
required environment variables:
eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"
To install Perl modules (for example Sort::Versions
), use the following
command after loading a Perl module and activating your local library:
cpan -i Sort::Versions
Ensure the eval
command shown above is included in your job script if using
a local library.
Example jobs¶
Serial jobs¶
Here is an example job running on 1 core with 1GB RAM:
#!/bin/bash
#$ -cwd
#$ -j y
#$ -pe smp 1
#$ -l h_rt=1:0:0
#$ -l h_vmem=1G
module load perl
perl example.pl
Here is an example job running on 1 core with 1GB RAM, using the
Sort::Versions
Perl module defined in the Perl code:
#!/bin/bash
#$ -cwd
#$ -j y
#$ -pe smp 1
#$ -l h_rt=1:0:0
#$ -l h_vmem=1G
module load perl
eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"
perl example.pl