somewhere near the beginning.

Installing local Perl modules, using CPAN

Filed under: General — Alex @ 11:37 am 5/8/2004

Every once in a while, it turns out that there is some Perl module that I need to use that isn’t installed already on the server. Then, I have to go through all the hassle of trying to install it without root access, which can be a huge pain if you don’t know what you’re about. Others should benefit from my hard earned knowledge, so here is the easiest way to go about it:

Use the CPAN.pm module. It should already be installed. Call it using the command line

perl -MCPAN -eshell

If you have already installed it, the shell will come up right away; in that case, use the line

o conf init,

and follow along the next steps.

Complete all the configuration steps as prompted, except those which ask for the parameters for the perl Makefile.PL command and the make install command. For the first of these, you need to make perl install the module into a local directory; do so by entering the line

PREFIX = /home/username/usr/lib/perl5/site_perl/5.6.1

or the equivalent. The particular directory doesn’t matter, I just try to mimic the normal installation directory because when I install other possibly non-perl based programs locally, they can all be logically organized. For the make install , add the line

INSTALLMAN3DIR = /home/username/usr/lib/perl5/man/man3

to let make know where to place the manual files.

Once you’ve installed the module, you need to let your programs know where to find it. The easiest way to do so is to add the following line at the top of your programs:

use lib qw(/home/username/usr/lib/perl5/site_perl/5.6.1);

There is also a way to do this without using CPAN. Cf http://servers.digitaldaze.com/extensions/perl/modules.html. The same site also has alternative methods of calling the installed modules from your programs.

Possibly relevant posts:

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment