Installing Perl Libraries
The Perl versions available through module load are bare ones, provided without any extra Perl module. If you need such modules, you can install them in your own environment using the cpanm command.
Step-by-step guide#
Let's imagine that you want to install BioPerl that gathers Perl modules for biology. To do that, once logged on tars.pasteur.fr
- Look at the Perl versions available in module
Code Block (bash)
$ module av perl
- load the Perl version you want among the listed ones
Code Block (bash)
$ module load perl/5.22.0
- Decide where you want to put the Perl modules (subdirectory of your home, of a project space...). For the following example, it will be in
~/.local/perl.If it doesn't exist, the destination directory will be created. - Install the library with the
cpanmcommand now available in your environment. The command looks like
Code Block (bash)
$ cpanm -l /path/to/the/destination/directory LibraryName
In our example, the command is then
Code Block (text)
$ cpanm -l ~/.local/perl BioPerl
Here is whatcpanm does for you:
-
Downloads the sources of the module
--> Working on BioPerl Fetching http://www.cpan.org/authors/id/C/CD/CDRAUG/BioPerl-1.7.5.tar.gz ... OK Configuring BioPerl-1.7.5 ... OK 2. Checks if it depends on others Perl modules
==> Found dependencies: XML::LibXML, XML::DOM::XPath, IPC::Run, XML::LibXML::Reader, DBI, Test::Memory::Cycle, XML::DOM, GD, Test::Weaken, Test::RequiresInternet 3. If yes, starts to download and install each of them. It does it recursively to ensure that everything needed by your targeted Perl module will be put in your environment too
--> Working on XML::LibXML Fetching http://www.cpan.org/authors/id/S/SH/SHLOMIF/XML-LibXML-2.0134.tar.gz ... OK Configuring XML-LibXML-2.0134 ... OK Building and testing XML-LibXML-2.0134 ... OK Successfully installed XML-LibXML-2.0134 --> Working on XML::DOM::XPath Fetching http://www.cpan.org/authors/id/M/MI/MIROD/XML-DOM-XPath-0.14.tar.gz ... OK Configuring XML-DOM-XPath-0.14 ... OK ==> Found dependencies: XML::XPathEngine, XML::DOM --> Working on XML::XPathEngine Fetching http://www.cpan.org/authors/id/M/MI/MIROD/XML-XPathEngine-0.14.tar.gz ... OK Configuring XML-XPathEngine-0.14 ... OK Building and testing XML-XPathEngine-0.14 ... OK Successfully installed XML-XPathEngine-0.14 --> Working on XML::DOM Fetching http://www.cpan.org/authors/id/T/TJ/TJMATHER/XML-DOM-1.46.tar.gz ... OK Configuring XML-DOM-1.46 ... OK ==> Found dependencies: XML::RegExp --> Working on XML::RegExp Fetching http://www.cpan.org/authors/id/T/TJ/TJMATHER/XML-RegExp-0.04.tar.gz ... OK Configuring XML-RegExp-0.04 ... OK Building and testing XML-RegExp-0.04 ... OK Successfully installed XML-RegExp-0.04 Building and testing XML-DOM-1.46 ... OK Successfully installed XML-DOM-1.46 Building and testing XML-DOM-XPath-0.14 ... OK Successfully installed XML-DOM-XPath-0.14 4. Once all dependencies have been installed, install the targeted Perl module
Building and testing BioPerl-1.7.5 ... OK Successfully installed BioPerl-1.7.5 15 distributions installed 5. Ok, now the Perl module is installed in the destination directory but the Perl interpreter is not aware of it. To inform it, you have to set the environment variable
PERL5LIB.If you use the defaultbashshell, the command looks like
Code Block (bash)
$ PERL5LIB=/path/to/the/destination/directory/lib/perl5/; export PERL5LIB
That is, in our example
Code Block (bash)
$ PERL5LIB=~/.local/perl/lib/perl5/; export PERL5LIB
since Perl modules are indeed in that directory
Code Block (bash)
$ ls -1 ~/.local/perl/lib/perl5/
Bio/
BioPerl.pm
Devel/
ExtUtils/
IPC/
Test/
XML/
x86_64-linux-thread-multi/
- From now on, the installed Perl modules are in your PATH. You can use
perldoccommand to check it
Code Block (bash)
$ perldoc -l Bio::Seq
/pasteur/homes/<login>/.local/perl/lib/perl5/Bio/Seq.pm
- To avoid doing step 5 each time you log on
tars.pasteur.fr, copy and paste your custom line
Code Block (bash)
PERL5LIB=/path/to/the/destination/directory/lib/perl5/; export PERL5LIB
in your ~/.bashrc file or the resource file of your shell if you use another one than bash.
8. Alternatively, you can use in your perl code the use directive to point to your installed perl module collection. eg:
Code Block (perl)
#!/usr/bin/env perl
#assume perl modules are located in ~/.local directory
use $ENV{"HOME"} . '/' . ".local";
Related articles#
Related articles appear here based on the labels you select. Click to edit the macro and add or change labels.
false5IISfalsemodifiedtruepagelabel in ("perl","libraries","cpan") and type = "page" and space = "IIS"perl libraries cpan
true
| Related issues |