Difference between revisions of "HPC:Perl"

From HPC wiki
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
=== Perl ===
 
Perl version 5.10.1 has been installed across the cluster, along with the popular BioPerl libraries.  
 
Perl version 5.10.1 has been installed across the cluster, along with the popular BioPerl libraries.  
  
Line 103: Line 104:
 
export MANPATH=$PERL5LIB/man:$MANPATH
 
export MANPATH=$PERL5LIB/man:$MANPATH
 
</pre>
 
</pre>
 +
 +
====  Running Perl scripts non-interactively ====
 +
 +
Shown below is a sample Perl script:
 +
<pre>
 +
$ cat simple.pl
 +
#!/usr/bin/env perl
 +
use warnings;
 +
print "Hello!\n";
 +
</pre>
 +
 +
The above script can be run on the PMACS HPC cluster:
 +
 +
<pre>
 +
$ bsub -e simple.e -o simple.o perl simple.pl
 +
</pre>
 +
 +
=== Other Pages ===
 +
----
 +
<div class="mw-collapsible mw-collapsed">
 +
*[[HPC:FAQ|HPC FAQ ]]
 +
*[[HPC:Login|Connecting to the PMACS cluster]]
 +
*[[HPC:User_Guide|User Guide]]
 +
*[[HPC:Software|Available Software]]
 +
*[[HPC:Archive System|PMACS Archive System]]
 +
</div>

Latest revision as of 15:45, 13 August 2019

Perl

Perl version 5.10.1 has been installed across the cluster, along with the popular BioPerl libraries.

User installed Perl Modules from CPAN using CPAN Minus

CPAN Minus is a light-weight replacement for CPAN. In order to install your own Perl modules, you can use the CPAN Minus tool (cpanm) with the --local-lib option:

[asrini@node063 ~]$ cpanm --help
Usage: cpanm [options] Module [...]

Options:
  -v,--verbose              Turns on chatty output
  -q,--quiet                Turns off the most output
  --interactive             Turns on interactive configure (required for Task:: modules)
  -f,--force                force install
  -n,--notest               Do not run unit tests
  --test-only               Run tests only, do not install
  -S,--sudo                 sudo to run install commands
  --installdeps             Only install dependencies
  --showdeps                Only display direct dependencies
  --reinstall               Reinstall the distribution even if you already have the latest version installed
  --mirror                  Specify the base URL for the mirror (e.g. http://cpan.cpantesters.org/)
  --mirror-only             Use the mirror's index file instead of the CPAN Meta DB
  --prompt                  Prompt when configure/build/test fails
  -l,--local-lib            Specify the install base to install modules
  -L,--local-lib-contained  Specify the install base to install all non-core modules
  --auto-cleanup            Number of days that cpanm's work directories expire in. Defaults to 7

Commands:
  --self-upgrade            upgrades itself
  --info                    Displays distribution info on CPAN
  --look                    Opens the distribution with your SHELL
  -V,--version              Displays software version

Examples:

  cpanm Test::More                                          # install Test::More
  cpanm MIYAGAWA/Plack-0.99_05.tar.gz                       # full distribution path
  cpanm http://example.org/LDS/CGI.pm-3.20.tar.gz           # install from URL
  cpanm ~/dists/MyCompany-Enterprise-1.00.tar.gz            # install from a local file
  cpanm --interactive Task::Kensho                          # Configure interactively
  cpanm .                                                   # install from local directory
  cpanm --installdeps .                                     # install all the deps for the current directory
  cpanm -L extlib Plack                                     # install Plack and all non-core deps into extlib
  cpanm --mirror http://cpan.cpantesters.org/ DBI           # use the fast-syncing mirror

You can also specify the default options in PERL_CPANM_OPT environment variable in the shell rc:

  export PERL_CPANM_OPT="--prompt --reinstall -l ~/perl --mirror http://cpan.cpantesters.org"

Type `man cpanm` or `perldoc cpanm` for the more detailed explanation of the options.


[asrini@node063 ~]$ cpanm -l perl5 Astro::Time
--> Working on Astro::Time
Fetching http://www.cpan.org/authors/id/C/CP/CPHIL/Astro-0.75.tar.gz ... OK
Configuring Astro-0.75 ... OK
Building and testing Astro-0.75 ... OK
Successfully installed Astro-0.75
1 distribution installed

[asrini@node063 ~]$ tree perl5/
perl5/
├── lib
│   └── perl5
│       ├── Astro
│       │   ├── Coord.pm
│       │   ├── Misc.pm
│       │   └── Time.pm
│       └── x86_64-linux-thread-multi
│           ├── auto
│           │   └── Astro
│           └── perllocal.pod
└── man
    └── man3
        ├── Astro::Coord.3pm
        ├── Astro::Misc.3pm
        └── Astro::Time.3pm

8 directories, 7 files

Installing other perl tools not in CPAN

Refer to the tool's documentation, but usually you supply a PREFIX or INSTALL_BASE to perl Makefile.PL.

Configuring your Perl environment to use local Modules

In order to take advantage of these modules and manpages, you will need define a directory to install them to as well as set a proper value for PERL5LIB.

To define the proper environment variables, you can use the perl5lib environment module:

# add to .bashrc or .tchsrc file
module load perl5lib

Alternatively, you can put the following in your .bashrc file:

 
export PERL5LIB=~/perl5/
export PATH=$PERL5LIB/bin:$PATH
export MANPATH=$PERL5LIB/man:$MANPATH

Running Perl scripts non-interactively

Shown below is a sample Perl script:

$ cat simple.pl
#!/usr/bin/env perl
use warnings;
print "Hello!\n";

The above script can be run on the PMACS HPC cluster:

$ bsub -e simple.e -o simple.o perl simple.pl

Other Pages