Installing Perl Modules from CPAN

Home / Installing Perl Modules from CPAN

Installing Perl Modules from CPAN

December 9, 2015 | Article | No Comments

CPAN, Comprehensive Perl Archive Network, is the largest working repository of perl archive and modules.

There are several ways to get Perl modules from CPAN installed on your unix-based system. Keep in mind that there is always more than one way to do it with Perl, and this is no different. Before embarking upon any installation, it’s a good idea to download the module, unzip it and check out the documentation. In general, though, most modules are installed in the same method.

The simplest way to get Perl modules installed is to use the CPAN module itself. If you are the system administrator and want to install the module system-wide, you’ll need to switch to your root user. To fire up the CPAN module, just get to your command line and run this:

perl -MCPAN -e shell

If this is the first time you’ve run CPAN, it’s going to ask you a series of questions – in most cases the default answer is fine. Once you find yourself staring at the cpan> command prompt, installing a module is as easy as install MODULE::NAME – for example, to install the HTML::Template module you’d type:

install HTML::Template

CPAN should take it from there and you’ll wind up with the module installed into your Perl library.

Let’s say you’re on your system command line and you just want to install a module as quickly as possible – you can run the Perl CPAN module via command line perl and get it installed in a single line:

perl -MCPAN -e 'install HTML::Template'

As mentioned earlier, it’s always advisable to download a module yourself, especially if you’re having problems installing with CPAN. If you’re on the command line, you can use something like wget to grab the file. Next you’ll want to unzip it with something like:

tar -xzvf HTML-Template-2.8.tar.gz

It is recommended to look around the source code’s root directory and read for the README or INSTALL files.

Then do installation:

perl Makefile.PL
make test
make install

About Author

about author


A man who is obsessed to low level technology.

Leave a Reply

Your email address will not be published. Required fields are marked *

Social Share Buttons and Icons powered by Ultimatelysocial