In order to install perl modules on C1, you will need to create a local perl library. In this example we will create our local library in a hidden directory within your home directory.
.perl
cd $HOME
mkdir .perl
cpanm
package manager and the local::lib
package.wget -O- http://cpanmin.us | perl - -l $HOME/.perl5 App::cpanminus local::lib
This what what the commands do:
wget -O- http://cpanmin.us
fetches the latest version of cpanm
and prints it to STDOUT
which
is then piped to perl - -l $HOME/.perl5 App::cpanminus local::lib
.
The first -
tells perl
to expect the program to come in on STDIN
,
this makes perl
run the version of cpanm
we just downloaded. perl
passes the rest of the arguments
to cpanm
. The -l $HOME/.perl5
argument tells cpanm where to install Perl modules,
and the other two arguments are two modules to install. App::cpanmins
is the package that installs cpanm
.
local::lib
is a helper module that manages the
environment variables needed to run modules in local directory.
local::lib
eval $(perl -I $HOME/.perl5/lib/perl5 -Mlocal::lib=$HOME/.perl5)
.bashrc
This enables the local perl library every time you login:
echo 'eval $(perl -I $HOME/.perl5/lib/perl5 -Mlocal::lib=$HOME/.perl5)' >> .bashrc
echo 'export MANPATH=$HOME/.perl5/man:$MANPATH' >> .bashrc
Perl packages can now be installed using cpanm Module::Name
.
For example, run the following command to install Log4perl
:
cpanm Log::Log4perl