Perl
From ScientificComputing
Please note that this application page is referring to the old CentOS software stack which is obsolete and does not work any more with the new Ubuntu setup. You can find an overview on the Ubuntu software stack on this wiki page.
Contents
Category
Development, Scripting, PerlDescription
Perl 5 is a highly capable, feature-rich programming language with over 29 years of development. Perl 5 runs on over 100 platforms from portables to mainframes and is suitable for both rapid prototyping and large scale development projects.Available versions (Euler, old software stack)
Legacy versions | Supported versions | New versions |
---|---|---|
5.16.3, 5.24.1 |
Please note that this page refers to installations from the old software stack. There are two software stacks on Euler. Newer versions of software are found in the new software stack.
Environment modules (Euler, old software stack)
Version | Module load command | Additional modules loaded automatically |
---|---|---|
5.16.3 | module load new gcc/4.8.2 perl/5.16.3 | |
5.24.1 | module load new gcc/4.8.2 perl/5.24.1 |
Please note that this page refers to installations from the old software stack. There are two software stacks on Euler. Newer versions of software are found in the new software stack.
Interactive session
Unlike Python and Java, Perl does not provide an interactive console. But it is possible to execute Perl command in your shell. For running the command print "Hello\n" in a shell, you need to call perl -e.[sfux@eu-login-05 ~]$ module load new gcc/4.8.2 perl/5.16.3 Now run 'perl-init' to initialize your environment for Perl [sfux@eu-login-05 ~]$ perl-init [sfux@eu-login-05 ~]$ perl -e 'print "Hello\n";' Hello [sfux@eu-login-05 ~]$There are some additional Perl packages, which provide an interactive Perl console, but they are not fully supported on our clusters.
How to submit a job
You can submit a Perl job (my_perl_script.pl) in batch mode with the following command:sbatch [Slurm options] --wrap="perl my_perl_script.pl"
Here you need to replace [Slurm options] with Slurm parameters for the resource requirements of the job. Please find a documentation about the parameters of sbatch on the wiki page about the batch system.
If you specify the Perl interpreter on the first line of your script, then please use
#!/usr/bin/env perl
instead of
#!/usr/bin/perl
Otherwise the Perl interpreter from the operating system will be called when you directly execute the script with
./my_perl_script.pl
instead of
perl ./my_perl_script.plThe Perl interpreter from the operating system is older and does not have the additional packages installed.
Example
As an example for a Perl job, we are looking at a script, that prints all environment variables for the current shell.[leonhard@euler04 ~]$ cat test.pl #!/usr/bin/env perl # This script prints out all environment varibles of the current shell. my @keys = keys(%ENV); while(my $key = shift @keys) { print "$key=$ENV{$key}\n"; } [leonhard@euler04 ~]$ module load new gcc/4.8.2 perl/5.16.3 Now run 'perl-init' to initialize your environment for Perl [leonhard@euler04 ~]$ perl-init [leonhard@euler04 ~]$ bsub -n 1 -W 0:30 -R "rusage[mem=10]" perl test.pl Generic job. Job <30746346> is submitted to queue <normal.4h>. [leonhard@euler04 ~]$ bjobs JOBID USER STAT QUEUE FROM_HOST EXEC_HOST JOB_NAME SUBMIT_TIME 30746346 leonhard PEND normal.4h euler04 *l test.pl Oct 27 12:33 [leonhard@euler04 ~]$ bjobs JOBID USER STAT QUEUE FROM_HOST EXEC_HOST JOB_NAME SUBMIT_TIME 30746346 leonhard RUN normal.4h euler04 e1243 *python.py Oct 27 12:35 [leonhard@euler04 ~]$ bjobs No unfinished job found [leonhard@euler04 ~]$ grep PERL lsf.o30746346 PERLBREW_MANPATH=/cluster/apps/perl5/perls/perl-5.16.3/man PERLBREW_VERSION=0.73 PERLBREW_PATH=/cluster/apps/perl5/bin:/cluster/apps/perl5/perls/perl-5.16.3/bin PERLBREW_ROOT=/cluster/apps/perl5 PERLBREW_PERL=perl-5.16.3 PERLBREW_BASHRC_VERSION=0.73The output of the Perl script is written to the lsf.o30746346 file.