Perl
Availability on SciNet systems
Perl 5.8.8 is installed on both the GPC and the TCS. While perl can be run without the need to load any software modules, but some of perl's functionality (especially installing modules from CPAN) relies on the GNU c compiler, so if you use perl on the GPC you most likely want to load the gcc module in your .bashrc:
module load gcc
Note: if, as we encourage, you use the intel compilers on the gpc as well, you should load the intel module after the gcc module to ensure that the environment variable are set properly.
Perl modules
One of the nice features of perl is the large number of perl modules that are out there. The Comprehensive Perl Archive Network (CPAN) is a large repository for these modules.
Note: perl modules are internal to perl are should not be confused with the software module system.
There are so many perl modules that we cannot possible maintain all of these. A number of module come with perl out-of-the-box and are therefore available. To find out what those are, you can use the command
$ perl -MFile::Find=find -MFile::Spec::Functions -Tlw -e 'find { wanted => sub { print canonpath $_ if /\.pm\z/ },no_chdir => 1 }, @INC'
Local perl modules from CPAN
Users are generally responsible for installing any other modules they need (although we can always help). This poses a slight hurdle, as CPAN's package system would try to install these in system directories to which users have no access. Fortunately, there is an easy way to setup CPAN to use a local folder for perl libraries.
In the following, the local directory for perl libraries will be assumed to be ~/perl5. For the most recent version of CPAN (which is required to install several modules and to use the local modules), follow the steps outlined below.
Modifications to .bashrc
A number of paths need to be set for perl to find the local modules you will install.
export PERL_LOCAL_LIB_ROOT="/home/[username]/perl5"; export PERL_MB_OPT="--install_base /home/[username]/perl5"; export PERL_MM_OPT="INSTALL_BASE=/home/[username]/perl5"; export PERL5LIB="/home/[username]/perl5/lib/perl5/x86_64-linux-thread-multi:/home/[username]/perl5/lib/perl5"; export PATH="/home/[username]/perl5/bin:$PATH";
Replace [username] with your username in each path.
Setting up a user-space CPAN modules directory
The following only works for the GPC (for now).
1. First, since installing perl modules may involve compilation, be sure to be on a devel node (e.g. ssh gpc01). On the gpc, make sure that the gcc module is loaded (module load gcc).
2. If this is not your first time using CPAN (for instance, you have tried before using it and found that you could not install any packages), you may have to remove your ~/.cpan directory. This will trigger a new configuration in the next step.
3. Start a CPAN shell:
$ cpan
4. It will ask you whether you are ready for a manual configuration. Say yes (or <enter>).
5. It will now ask you a bunch of questions, almost all of which you can answer with the default (i.e. press <enter>), except for one: When the installation asks for Parameters for the 'perl Makefile.PL' command, enter:
LIB=~/perl5/lib/perl5 INSTALLMAN1DIR=~/perl5/man/man1 INSTALLMAN3DIR=~/perl5/man/man3
(all on one line).
6. When it asks for the repository to use, you can pick what you want. I chose #6, for no particular reason.
7. A module called local::lib is required to read the .bashrc environment variables properly. To install the latest local::lib , type install local::lib in the CPAN shell and press <enter>.
8. As the module is installing, numerous prerequisites will also be installed (including an updated version of CPAN). Answer each with the default option.
9. When installation completes, there will be an error. Disregard the error for now. First type exit into the cpan shell.
10. Now you should be back to the regular terminal. Restart the cpan shell. The shell will ask if you want to configure as much as possible automatically. Choose yes.
11. Install local::lib as you did in step 7 and now everything should install without errors.
Installing CPAN modules
Either from the CPAN shell or from the command line, you can now install packages quite simly by perl -MCPAN -e install <perlmodule> or simply cpan <perlmodule>.
Using the modules
You can use local perl modules just as you would use system-wide perl modules.