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 perl
to see which versions are installed and then
[name@server $] module load perl/5.22.2
to load a particular version.
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.
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).
Using the Local::Lib Package to Install Packages
An alternative approach, based on the Perl package local::lib, is the following - you can simply copy and paste the commands into your terminal for it to work.
# install local::lib wget http://search.cpan.org/CPAN/authors/id/H/HA/HAARG/local-lib-2.000018.tar.gz tar -xzf local-lib-2.000018.tar.gz cd local-lib-2.000018 perl Makefile.PL --bootstrap make test && make install # setting up appropriate environment variables so that perl knows about our new ~/perl5/lib directory cd ~ echo 'eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"' >> ~/.bashrc source ~/.bashrc # check that local::lib is indeed installing to the right directory, you should see a bunch of paths beginning with ~/perl5/lib/perl5/ get printed out perl -e 'print "@INC"'