The CPAN Module


© Philip Yuson
Articles in this Topic    Discussions in this Topic

Who is this for
This article is for those who want to be familiar with the CPAN module.

What you need to know
Skills in compilation and linking

Introduction
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, Tk and CGI modules. These have been discussed in this site in previous months.

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.

Another way 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.

To install the modules yourself, you might need the compiler and maker. You might also need include files from other components of your system.

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).

CPAN shell
CPAN 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 shell.

Starting the CPAN Shell

On the command line type this:
perl -MCPAN -e shell

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 shell.

Getting Help
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.

Displaying Modules
To display modules whose name has a given string, you can use the m or i commands:

m /string/ or i /string/

The string is any valid regular expression. You can also browse all modules from the CPAN website. Modules names appear before the ::

Go To Page: 1 2


Post this Article to facebook Add this Article to del.icio.us! Digg this Article furl this Article Add this Article to Reddit Add this Article to Technorati Add this Article to Newsvine Add this Article to Windows Live Add this Article to Yahoo Add this Article to StumbleUpon Add this Article to BlinkLists Add this Article to Spurl Add this Article to Google Add this Article to Ask Add this Article to Squidoo