is this for
This article is for those who want to be familiar
with the CPAN module.
What you need to know
in compilation and linking
One of the
features of Perl is its extensibility. This feature allows you to
extend the capabilities of the Perl language beyond its core
functions. Examples of these extensions are the DBI,
modules. These have been discussed in this site in previous
These and the other modules have to be installed. The
simplest and easiest way is to find a distribution for these modules
and installing them. Different distributions of Linux provide their
own methods of distributing these modules. Likewise, different
distributions of Perl in Windows have their own way of installing
these modules. As I said, the simplest way to install these modules
is to use the method provided by the distribution.
of installing the modules is by configuring and make-ing these
modules yourselves. This requires compilation and link process
knowledge. For simple modules, it would be straightforward, at most,
4 steps (configure or create the make file, make, make test and make
install). But for modules with pre-requisites, you will need to first
determine the pre-requisites before you can install them.
install the modules yourself, you might need the compiler and maker.
You might also need include files from other components of your
To make your life simpler, install modules from
any pre-built modules.
You also need to download the
modules from the CPAN website (http://www.cpan.org).
is an acronym for Comprehensive Perl Archive Network. Perl provides a
process to simpify installing CPAN modules. It uses the CPAN module
and you can install other modules using the shell or directly from
the Perl command line.
This article discusses the CPAN
Starting the CPAN Shell
On the command
line type this:
The first time you start CPAN,
it will ask you several questions. You can take the default and it
would be fine. Make sure that you have write access to your Perl
directories. You should always use the same userid wen using the CPAN
When you start the CPAN
shell, you can enter commands to control its operation. The most
important command is h. This lists all the commands that you can use
in the CPAN shell.
display modules whose name has a given string, you can use the m
or i commands:
The string is any valid
regular expression. You can also browse all modules from the CPAN
website. Modules names appear before the :: characters.
One of the reasons for using
CPAN is to simplify installation. If your module requires other
modules and these requisite modules are not installed, CPAN will
install them automatically for you.
To install modules, type:
you install a module, CPAN will create the makefile, make the module,
test it and then install it in one step.
To install the Tk
module, you can do this:
install the HTML::Mason module, you do this:
There will be times when the CPAN install would
not work. You might have to force the installation ONLY if you are
sure that the error is acceptable. Otherwise, you will have to
manually install the module.
To force installation, you can
will install the module even if CPAN encounters errors during