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
module load perl
Not all Perl modules are installed on Henry2. If you need additional Perl modules you can install new Perl modules by yourself.
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 LSF's bsub. 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.csh:
#!/bin/csh #BSUB -W 10 #BSUB -n 1 #BSUB -o out.%J #BSUB -e err.%J module load perl perl hello.pl
Then use
bsub < submit.csh
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.
/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.
module load perl
perl -M<module name> -e 1If 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 ~]$
mkdir /usr/local/usrapps/jdian/perl-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
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 setenv PATH /usr/local/usrapps/jdian/perl-modules/bin:$PATHFor 3), do
setenv PERL5LIB /usr/local/usrapps/jdian/perl-modules/lib/perl5/x86_64-linux-thread-multi:/usr/local/usrapps/jdian/perl-modules/lib/perl5:$PERL5LIBIf the command returns error message "PERL5LIB: Undefined variable." which means PERL5LIB is not set up yet, then simply do:
setenv PERL5LIB /usr/local/usrapps/jdian/perl-modules/lib/perl5/x86_64-linux-thread-multi:/usr/local/usrapps/jdian/perl-modules/lib/perl5Below is a sample job script for using Perl modules installed in your own directory
#!/bin/tcsh #BSUB -W 20 #BSUB -n 1 #BSUB -o out.%J #BSUB -e err.%J module load perl setenv PATH /usr/local/usrapps/jdian/perl-modules/bin:$PATH setenv 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>
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 23 2022 13:21:34.