Perl
This is not a complete article: This is a draft, a work in progress that is intended to be published into an article, which may or may not be ready for inclusion in the main wiki. It should not necessarily be considered factual or authoritative.
Description
Perl is a free programming language which is interpreted and has acquired a vast library of contributed packages over the 25+ years of its existence. Its strengths are manipulating strings, database access and its portability (according to this article). Its weaknesses are its poor performance and the ease with which one can write obscure and illegible code. By design, Perl offers several different ways of accomplishing the same task. Many programmers have adopted this language and write code that is very compact but difficult to decipher.
Loading the Interpreter
The Perl language is made available on Compute Canada's servers using a module which you can load like any other, e.g.
[name@server ~]$ module avail python
to see which versions are installed and then
[name@server ~]$ module load perl/5.22.2
to load a particular version.
Installing Packages
A large number of Perl packages can be installed by means of the Comprehensive Perl Archive Network, by using the tool cpan, which however must first be initialized correctly in order to install them in your home directory.
Initial Configuration for Package Installation
During the first execution of the command cpan the utility will ask you if you want to allow it to configure the majority of settings automatically. Respond yes.
[name@server ~]$ cpan
...
Would you like me to configure as much as possible automatically? [yes]
...
Afterwards, use the following commands to change your installation directory:
> o conf mbuildpl_arg "--install_base ~/perl/"
> o conf makepl_arg "PREFIX=~/perl/"
> o conf commit
> exit
Note that it is important to quit cpan at this stage and to restart it so that the new settings are used.
Package Installation
When the initial configuration is done, you can install any of the more than 25,000 packages available on CPAN. For example:
[name@server ~]$ cpan
cpan shell -- CPAN exploration and modules installation (v1.7602)
ReadLine support available (try 'install Bundle::CPAN')
cpan> install PerlIO::gzip
...
Running install for module PerlIO::gzip
Running make for N/NW/NWCLARK/PerlIO-gzip-0.18.tar.gz
Fetching with LWP:
ftp://CPAN.mirror.rafal.ca/pub/CPAN/authors/id/N/NW/NWCLARK/PerlIO-gzip-0.18.tar.gz
CPAN: Digest::MD5 loaded ok
Fetching with LWP:
ftp://CPAN.mirror.rafal.ca/pub/CPAN/authors/id/N/NW/NWCLARK/CHECKSUMS
...
CPAN.pm: Going to build N/NW/NWCLARK/PerlIO-gzip-0.18.tar.gz
Checking if your kit is complete...
Looks good
Writing Makefile for PerlIO::gzip
...
Running make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/read.....ok
t/write....ok
All tests successful.
Files=2, Tests=561, 0 wallclock secs ( 0.37 cusr + 0.05 csys = 0.42 CPU)
...
Running make install
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Lastly, you must add the path of your installation directory to your environment. You can do this by adding the following line to your .bashrc:
[name@server ~]$ export PERL5LIB=$HOME/perl/lib64/perl5:$HOME/perl/share/perl5
(assuming that you have installed the packages in the directory $HOME/perl).