Installing Perl CPAN Modules
While we are happy to install new packages on our systems for use by all our users, it is sometimes more appropriate for individual users to install specialized programs or modules in their home directories, for their exclusive use.
The following is a guide to installing Perl modules in your home directory on the CS Linux platform. The module you wish to install must already exist on CPAN [cpan.org]. This guide does not teach you how to install Perl modules which you have created.
Starting Fresh
Skip this step if you have previously used this guide. Skip this step if you have CPAN settings you wish to preserve. Do not skip this step if you have not used the CPAN command interface before.
First, remove any already existing CPAN configurations, and create the directory in which the Perl module(s) will reside:
$ rm -rf ~/.cpan $ mkdir ~/perl
Configuring CPAN
Set the FTP_PASSIVE environment variable to avoid conflicts with our firewalls. Then configured cpan:
$ FTP_PASSIVE=1; export FTP_PASSIVE $ /opt/techstaff/bin/configure_cpan
Installing the Module (with CPAN)
Find the module on CPAN's search interface, and it's exact name. This should be something like Category::Module, Crypt::RSA (used as an example below), etc.
At the shell, type:
perl -MCPAN -e 'install install Category::Module'
...where Category::Module is the full name of the module you are trying to install.
CPAN will then identify, download, and install the module into your home directory. You may have to answer several questions first.
If the module you wish to install has unsatisfied dependencies, you will be prompted as such:
---- Unsatisfied dependencies detected during [V/VI/VIPUL/Crypt-RSA-1.55.tar.gz] -----
Tie::EncryptedHash
Crypt::Blowfish
Crypt::Random
Convert::ASCII::Armour
Crypt::CBC
Digest::MD2
Math::Pari
Class::Loader
Sort::Versions
Crypt::Primes
Data::Buffer
Shall I follow them and prepend them to the queue
of modules we are processing right now? [yes]
In general, answering "yes" is appropriate. Sometimes, however, there may be too many dependencies to install or the installation will fail. In those cases, it is best to contact techstaff for assistance, or to try to install the module manually (not described here). Also, dependencies may have dependencies of their own to install.
CPAN will now download and install all dependencies, then your module. CPAN will prompt you if it has any questions about what to do, such as the following:
Did not find GP/PARI build directory around.
Do you want to me to fetch GP/PARI automatically?
(If you do not, you will need to fetch it manually, and/or direct me to
the directory with GP/PARI source via the command-line option paridir=/dir)
Make sure you have a large scrollback buffer to see the messages.
Fetch? (y/n, press Enter)
In general, the defaults work. Only you will know how you want your Perl module configured, since you are going to be the one using it, so use your best judgment in answering these questions.
Sometimes, modules need to be forcefully installed. Use this feature with caution:
perl -MCPAN -e 'force install Crypt::RSA'
...will forcefully install the module Crypt::RSA. We advise that you attempt to debug errors in installation rather than forcing installation. Forcing may produce an unusable or unreliable Perl module, as some errors during installation are ignored.
Using your module
In order to have Perl recognize the existence of modules installed into the home directory, it must know where to look. You can tell Perl to look in a certain directory for modules in three ways: through an environment variable, with an argument, or with "use lib" within your program. Here are examples of how, in that order:
$ PERL5LIB=/home/$USER/perl/lib/perl perl myscript.pl $ perl -I/home/$USER/perl/lib/perl myscript.pl
...or within your Perl script:
use lib "$ENV{HOME}/perl/lib/perl";
no lib ".";
You should now be able to use the new Perl module.

