Perl
Perl is a family of two high-level, general-purpose, interpreted, dynamic programming languages. "Perl" usually refers to Perl 5.
External Links:
Perl website
Perl: Learn about it
Load Perl
To load the Perl 5 environment, usemodule load perl
Not all Perl modules are installed on Hazel. If you need additional Perl modules you can install new Perl modules by yourself.
Run Perl jobs
Do not use Perl directly on a login node for anything other than installing new Perl modules. You need to submit jobs as batch jobs to Slurm's sbatch. For more information on submitting batch jobs, see the documentation on running jobs.
For a Perl Hello World program called hello.pl, below is a sample batch job script submit.sh:
#!/bin/bash #SBATCH --time=00:10:00 #SBATCH --ntasks=1 #SBATCH --output=out.%j #SBATCH --error=err.%j module load perl perl hello.pl
Then use
sbatch submit.sh
to submit the batch job. The above job script will request one core for 10 minutes. Check the documentation on running jobs to customize the batch script.
Install new Perl modules by yourself
Your home disk quota limited, only 1GB. Thus, generally, you don't want to should install apps, such as Perl modules, in your home directly, unless you know the size of the apps are pretty small. HPC provides a location for users to install apps. It is:/usr/local/usrappsTo install apps there you need to make a formal request. Please visit Request space for user maintained software to learn how to make the request.
The instructions below are based on installing new Perl modules in user jdian's directory
/usr/local/usrapps/jdian/perl-modulesIn your own installations, you need to replace "/usr/local/usrapps/jdian/perl-modules" by your own directory path in all the commands and job scripts. However, DON'T make any changes in lower level subdirectory names since those names are automatically generated by Perl.
- Set up Perl environment
module load perl
- Check whether a module is already installed
perl -M<module name> -e 1
If you don't get any output from the above command then the module is installed; and if you get error message, then it's not installed. Below are some checking examples. The first three are installed and the other two are not:[jdian@login02 ~]$ perl -MThread::Queue -e 1 [jdian@login02 ~]$ perl -MThread -e 1 [jdian@login02 ~]$ perl -MTie::Hash -e 1 [jdian@login02 ~]$ [jdian@login02 ~]$ perl -MClarion -e 1 Can't locate Clarion.pm in @INC (you may need to install the Clarion module) (@INC contains: /usr/local/apps/perl5/perlbrew/perls/perl-5.28.0/lib/site_perl/5.28.0/x86_64-linux-thread-multi /usr/local/apps/perl5/perlbrew/perls/perl-5.28.0/lib/site_perl/5.28.0 /usr/local/apps/perl5/perlbrew/perls/perl-5.28.0/lib/5.28.0/x86_64-linux-thread-multi /usr/local/apps/perl5/perlbrew/perls/perl-5.28.0/lib/5.28.0). BEGIN failed--compilation aborted. [jdian@login02 ~]$ [jdian@login02 ~]$ perl -MClass::Closure -e 1 Can't locate Class/Closure.pm in @INC (you may need to install the Class::Closure module) (@INC contains: /usr/local/apps/perl5/perlbrew/perls/perl-5.28.0/lib/site_perl/5.28.0/x86_64-linux-thread-multi /usr/local/apps/perl5/perlbrew/perls/perl-5.28.0/lib/site_perl/5.28.0 /usr/local/apps/perl5/perlbrew/perls/perl-5.28.0/lib/5.28.0/x86_64-linux-thread-multi /usr/local/apps/perl5/perlbrew/perls/perl-5.28.0/lib/5.28.0). BEGIN failed--compilation aborted. [jdian@login02 ~]$
- Create the installation directory if it is not already there:
mkdir /usr/local/usrapps/jdian/perl-modules
- Install new modules.
The command to install a new module into the directory /usr/local/usrapps/jdian/perl-modules is
cpanm -l /usr/local/usrapps/jdian/perl-modules <module name>
For examples, the commands for installing new modules "Clarion" and "Class::Closure" are:cpanm -l /usr/local/usrapps/jdian/perl-modules Clarion cpanm -l /usr/local/usrapps/jdian/perl-modules Class::Closure
- Use modules installed in your own directory
When you need to use the modules you have installed in your own directory, you need to do three things: 1) set up Perl environment, 2) add the bin directory in the location of your own modules to your environment variable PATH, and 3) add two relevant directories in the location of your own modules to Perl module search path. Below are the commands to do those.
For 1) and 2) do
module load perl export PATH = /usr/local/usrapps/jdian/perl-modules/bin:$PATH
For 3), doexport PERL5LIB = /usr/local/usrapps/jdian/perl-modules/lib/perl5/x86_64-linux-thread-multi:/usr/local/usrapps/jdian/perl-modules/lib/perl5:$PERL5LIB
If the command returns error message "PERL5LIB: Undefined variable." which means PERL5LIB is not set up yet, then simply do:export PERL5LIB = /usr/local/usrapps/jdian/perl-modules/lib/perl5/x86_64-linux-thread-multi:/usr/local/usrapps/jdian/perl-modules/lib/perl5
Below is a sample job script for using Perl modules installed in your own directory#!/bin/bash #SBATCH --time=00:20:00 #SBATCH --ntasks=1 #SBATCH --output=out.%j #SBATCH --error=err.%j module load perl export PATH = /usr/local/usrapps/jdian/perl-modules/bin:$PATH export PERL5LIB = /usr/local/usrapps/jdian/perl-modules/lib/perl5/x86_64-linux-thread-multi:/usr/local/usrapps/jdian/perl-modules/lib/perl5 <your Perl commands>
- Find where a Perl module will be loaded from
After you set up Perl environment and the environment variable PERL5LIB, you can use the following command to see where a Perl module will be loaded from:
perldoc -l <module name>
See below are some actual checking examples[jdian@login02 ~]$ perldoc -l Thread::Queue /usr/local/apps/perl5/perlbrew/perls/perl-5.28.0/lib/5.28.0/Thread/Queue.pm [jdian@login02 ~]$ [jdian@login02 ~]$ perldoc -l Thread /usr/local/apps/perl5/perlbrew/perls/perl-5.28.0/lib/5.28.0/Thread.pm [jdian@login02 ~]$ [jdian@login02 ~]$ perldoc -l Clarion /usr/local/usrapps/jdian/perl-modules/lib/perl5/Clarion.pm [jdian@login02 ~]$ [jdian@login02 ~]$ perldoc -l Class::Closure /usr/local/usrapps/jdian/perl-modules/lib/perl5/Class/Closure.pm [jdian@login02 ~]$
Last modified: March 14 2026 09:24:21.