Jump to navigation Jump to search


perl website  

Perl 5 is a highly capable, feature-rich programming language with over 23 years of development.

Environment Modules

Run module spider perl to find out what environment modules are available for this application.

System Variables

  • HPC_PERL_DIR - installation directory
  • PERL5LIB - perl module path

Additional Information

Though modern-day Linux and Unix systems may have many perl modules already installed, the time may come when you use a module that was not shipped with your system or installed by your administrator. Don't fret - you can do this all by yourself by using the CPAN module. This document will describe how to use the CPAN module to install perl modules into a subdirectory of your home area which we'll call perl5lib.

Note: If you are using the perl module by running module load perl you can request installation of additional modules by filing a support request.

CPAN Module Configuration

  1. Execute the following command to start a CPAN shell:
    • $ perl -MCPAN -e shell
  2. The first time you run this, an interactive question and answer session will be started as CPAN configures itself. You can take all the defaults until it asks whether you want any parameters for perl Makefile.PL:
    • Every Makefile.PL is run by perl in a separate process.
    • ...
    • Your choice:  []
  3. You should answer with the following long line:
    • PREFIX=~/perl5lib/ LIB=~/perl5lib/lib INSTALLMAN1DIR=~/perl5lib/man1 INSTALLMAN3DIR=~/perl5lib/man3
  4. You can take defaults again until it comes time to choose mirrors of from which you can install from. Choose as many as you like; I chose:
  5. After choosing your mirrors, press enter until you get the cpan> prompt. Then quit (type 'q').
  6. Now tell perl to use your personal module repository by setting the PERL5LIB environment variable. For Bourne shell users, you would do this:
    • $ PERL5LIB=~/perl5lib/lib
    • $ export PERL5LIB
  7. You should also add the above two lines to your ~/.bash_profile so the PERL5LIB variable will be automatically set when you next log in.
  8. Then start up CPAN again:
    • $ perl -MCPAN -e shell
  9. You will be immediately greeted with the cpan> prompt. At the cpan> prompt, enter the following to get CPAN to update itself:
    • install Bundle::CPAN
    • reload cpan

and that's it!

Installing Additional Modules

Now that you have CPAN configured, you can install all the modules you want either from CPAN's interactive shell (perl -MCPAN -e shell) or from the command line (perl -MCPAN -e 'install FOO::BAR'). The modules will be installed into your ~/perl5lib/lib directory.

Expand this section to view example of module installation.

As a full example, we'll install the File::Slurp module into the username user's ~/perl5lib directory.

[user@submit2 ~]$ perl -MCPAN -e shell

cpan shell -- CPAN exploration and modules installation (v1.7602)
ReadLine support enabled

cpan> install File::Slurp
CPAN: Storable loaded ok
  /usr/bin/make install -j2 -- OK

With installation finished, we can test it interactively:

[user@submit2 ~]$ perl -e 'use File::Slurp;'

If all went well, the above command will return with no errors.