CSC Computing Environment

Perl

💬 Perl scripts and applications do not need installation. They can be simply downloaded and run.

💬 To run Perl applications, it usually best to first load a Perl module.

☝🏻 A system Perl installation is available (without a module), but it is very barebones and is missing many commonly used libraries.

  1. To check available module versions, use:
module spider perl
  1. The current default version is 5.34.1 and can be loaded with:
module load perl

☝🏻 To ensure scripts use the intended Perl version after loading a module you should either call the script with perl:

perl my_app.pl

or make sure the shebang line of the script is:

#!/usr/bin/env perl

Installing Perl modules

💬 Sometimes applications may require additional modules to run.

💬 You should check the installation instructions for each module. For libraries in CPAN, the easiest method is to use cpanm.

In this example, we’ll add the perl module JSON to our own environment

  1. Check if JSON is already available:
perl -e 'use JSON;'

🗯 By default, cpanm tries to install new modules to the Perl installation path, which will not work.

  1. Replace the desired path for PERL_BASE and run the following:
export PERL_BASE="/projappl/<project>/$USER/myperl"    # example, replace <project> with your CSC project, e.g. project_2001234
export PERL_MM_OPT="INSTALL_BASE=$PERL_BASE"
export PERL_MB_OPT="--install_base $PERL_BASE"
export PERL5LIB="$PERL_BASE/lib/perl5"
  1. You can now install the module. In this case, it is in CPAN, so you can use cpanm:
cpanm JSON
  1. To use the module, you need to tell Perl where to find it. In this case, you can set the $PERL5LIB environment variable (already done above):
export PERL5LIB="/projappl/<project>/$USER/myperl/lib/perl5"    # replace <project> with your CSC project, e.g. project_2001234
  1. You can now try again:
perl -e 'use JSON;'

Additional info

💬 The installation only needs to be done once, but you need to always ensure Perl knows where to find the installed modules.

💭 There are three main ways to do this (we used the second already):

Option 1

perl -I /projappl/<project>/$USER/myperl/lib/perl5 ./my_app.pl    # replace <project> with your CSC project, e.g. project_2001234

Option 2

export PERL5LIB=/projappl/<project>/$USER/myperl/lib/perl5:$PERL5LIB    # replace <project> with your CSC project, e.g. project_2001234

Option 3

use lib '/projappl/<project>/$USER/myperl/lib/perl5';
use My::Module;

Bioperl

💬 If you need the BioPerl collection of Perl modules, you can find this pre-installed on Puhti (try module spider bioperl).

💡 See our BioPerl documentation for more details.