Installing Perl modules – a reminder

October 3rd, 2007

The simplest way to install a Perl module is to use the Perl CPAN module. Of course you have to install this first. Once you have you can do perl -MCPAN -e 'install Collection::Module'

For example: perl -MCPAN -e 'install Magic::Invisibility'

If the module isn't available for installation this way, but a package is available for download at the CPAN Web site, or elsewhere, you can usually install it the manual way. For example, following my recent post about a login banner, I recently installed the Text::Banner module on a Linux server as follows:

wget http://search.cpan.org/CPAN/authors/id/L/LO/LORY/Text-Banner-1.00.tar.gz
gunzip Text*gz
tar xvf Text*tar
cd Banner
cat README

... [I read the README file at this point]

perl Makefile.PL
make
make test
make install
perl -MText::Banner -e 1

[no error message means it was installed successfully]

For more detail (including details of how to install into a non-standard location) see:

http://search.cpan.org/~jhi/perl-5.8.0/pod/perlmodinstall.pod

 


UPDATE (13/10/2007):

I always used to use the  perl -MCollection::Module -e 1 way of checking whether a module was installed. Another, in some ways better, way to check is to print the version number of a module. To do this enter the command:

perl -e "use Collection::Module; print $Collection::Module::VERSION";

For example:

perl -e "use SOAP::Lite; print $SOAP::Lite::VERSION";

If the module is installed, this either prints the version number or, if the module hasn't been built to report its version, a blank line.

If the module is not installed, you get a "Can't locate ..." error message.

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

Leave a comment