Skip to content

Perl

Description

perl website

Perl is a high-level programming language with an eclectic heritage written by Larry Wall and a cast of thousands. It derives from the ubiquitous C programming language and to a lesser extent from sed, awk, the Unix shell, and at least a dozen other tools and languages. Perl's process, file, and text manipulation facilities make it particularly well-suited for tasks involving quick prototyping, system utilities, software tools, system management tasks, database access, graphical programming, networking, and world wide web programming. These strengths make it especially popular with system administrators and CGI script authors, but mathematicians, geneticists, journalists, and even managers also use Perl. Maybe you should, too.

  • PERL5LIB - perl module directory

Environment Modules

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

Environment Variables

Additional Usage 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.

Tip

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 www.cpan.org from which you can install from. Choose as many as you like; I chose:

    ftp://mirrors.kernel.org/pub/CPAN/
    
    http://www.perl.com/CPAN/
    
  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... and that's it!

    install Bundle::CPAN
    
    reload cpan
    

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.

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
cpan> 

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.

Categories

programming, language