Installing Perl Libraries
This guide explains how to install Perl modules in a non-system location (e.g., project or group directory) using cpanm and local::lib.
This is ideal for environments where you cannot modify system Perl without root access, such as on RCAC clusters (Gautschi, Negishi, Bell).
-
Create the required directory in your desired location (e.g., home or project space).
You can substitute this path to any location you want (
~or even$SCRATCH) . -
Set up the environment to install Perl modules locally:
Paste the following into
env.sh:env.sh Then activate it:
Note
You can check which Perl is in use and where it looks for libraries by running
which perlandperl -Vcommands. Make sure it points to/usr/bin/perland includes/depot/gcore/localperl/lib/perl5in@INCafter activating your environment. -
Install
cpanm(Perl module installer) into the custom location:Warning
Make sure you've already run
source /depot/gcore/localperl/env.shbefore installing modules withcpanm, or they will be installed in the wrong location.Confirm that it worked:
-
Install the required Perl modules:
You can add more modules as needed.
-
(Optional) Automatically load your environment in future sessions:
If you prefer not to modify your
~/.bashrc, you can manually source the environment script each time you start a new session.Warning
Remember to run
source /depot/gcore/localperl/env.shin any new shell before running scripts that depend on these local modules.
Testing the installation¶
To verify that the installation was successful, you can run a simple Perl script that uses one of the installed modules:
| test_perl_modules.pl | |
|---|---|
Run the script:
If you see the message "Local Perl modules are working!", your installation is successful.