Installing perl packages locally

We’ve all been there -someone gives you some prewritten code to run and the first thing you try to do fails


[loggedin@host ~]$ ./ -i infile -o outfile

Can’t locate Package/ in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 at ./ line 17.

So whats the problem? Well, essentially it is that the perl module (in this case it would be Package::1) isn’t available from your installation

The solution. You need to install the perl module (Package::1) into a local library and point perl at it.  Here’s how…

1. find your package and download to your server

wget http://www.whereever.url/Package_1.tar.gz

2. untar and navigate into the directory

tar -zxvf Package_1.tar.gz

cd Package_1

3. build makefile specifying your local lib location

perl Makefile.PL PREFIX=~/lib/perl5 LIB=~/lib/perl5


make test #this will highlight other missing dependencies…

make install

4. point perl to this library – easiest way is to add the following line to your login via  ~/.bashrc in your favourite editor

export PERL5LIB=~/lib/perl5/  # save then  source the file  (source ~/.bashrc)

5. go back and do it all over again until it all works wonderfully

6. discover that the script you were given doesn’t do what you want anyway….