------Perl
💬 Perl scripts and applications do not need installation. They can be simply downloaded and run.
💬 To run Perl applications, it's usually best to first load a Perl module.
☝🏻 A system Perl installation is available (without a module), but it is very bare-bones and is missing many commonly used libraries.
To check available module versions, use:
The current default version is
5.34.1and can be loaded with:To ensure scripts use the intended Perl version after loading a module you should either call the script with
perl:or make sure the shebang line of the script is:
Installing Perl modules
💬 Sometimes applications may require additional modules to run.
These "Perl modules", should not be confused with the software modules on CSC supercomputers.
💬 You should check the installation instructions for each module. For libraries in CPAN, the easiest method is to use cpanm.
You can check out the CPAN documentation here.
In this example, we'll add the Perl module JSON to our own environment
Check if JSON is already available:
The error message indicates that it is not found, so you need to install it.
🗯 By default,
cpanmtries to install new modules to the Perl installation path, which will not work.You need to set the location to a directory where you have write access. It could be e.g. your project's
/projappldirectory.This is accomplished by setting a few environment variables.
Replace the desired path for
PERL_BASEand run the following:You can now install the module. In this case, it is in CPAN, so you can use
cpanm:To use the module, you need to tell Perl where to find it. In this case, you can set the
$PERL5LIBenvironment variable (already done above):You can now try again:
This time there's no error message, indicating that the JSON module is now available.
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
Pass the path using the command-line option
-I:
Option 2
Include the path in the
$PERL5LIBenvironment variable:
Option 3
Include the path in your Perl script with
use lib:
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.