:::PunLib | Welcome:::
PunLib Home Contacts PunLib on Facebook Follow PunLib on Twitter PunLib at LinkedIn RSS Feed Image Add This Logo
Quick Links
CPAN | Use

How to use CPAN

Official CPAN Logo

What is CPAN?

CPAN is the Comprehensive Perl Archive Network. It is online repository of modules of software in Perl language and related documentations. Most of the modules/software are free and open source. These are hosted at www.cpan.org. The repository is mirrored on 250+ servers worldwide.

The archive was started in 1995 and now it contains more than 103,000 perl modules contributed by more than 9400+ developers. The repository is constantly growing with more and more modules being added daily.

CPAN also denotes a utility in Perl world that can fetch and install any module from the CPAN repository and install it when required quite automatically. It can be invoked by typing a command. Many high-end perl based software distributions use these modules and mention the module names that need to installed before installing the applications in their documentation.



Perl can be invoked from command line by typing the command,

# cpan <>

The above method is quite straight forward but If you have a long list of perl modules or want to have better control/understanding of what you are installing or want to troubleshoot a failed installation you may want to enter the cpan console or cpan shell. In this case start with the command,

# perl -MCPAN -e shell

This will start the cpan console as under,


When installing from this console you need to type one of the commands mentioned bellow along with the module name. If you want to install a perl module called PDF::API2 the correct syntax will be,

cpan> install PDF::API2

Note: If you are using the cpan for the Ist time on your machine it will ask you to configure the service on your machine. You can opt for autoconfigure or do the configuration manually by answering a few questions and defining a few locations. However, auto-configuration will be sufficient for you if you are new to the utility or you can reply most of the time with default values if doing it manually. Anyway, you can return back and reconfigure if needed at any time by typing 'o conf init' at the command prompt.


While using cpan the commonly used commands are get, make, test and install. The functions of these commands are,

This will get/download the perl module from the cpan repository to your machine. Syntax -

cpan> get PDF::API2

This will make the downloaded module for installation.

cpan> make PDF::API2

This will test the installation for any missing dependencies or any other issues.

cpan> test PDF::API2

This will install the perl module. This command is all comprehensive i.e. if used alone along with the name of module this will execute all the commands mentioned above in the same sequence (this will download, make and test the module and then install it).

cpan> install PDF::API2

The better option will be to use the last command i.e. install as this will perform all the functions required for the installation. However, if you are facing some issues and the module is not installing you can perform one task starting with download through installation to find the cause of failure. Or simply if you are curious and want to go through all the steps one by one you can use these commands in the sequence.

Important: If required you can install more than one module with the same command by typing all the modules on the same line with a space inbetween at the command prompt, i.e.

cpan PDF::API2 Text::CSV XML::Dumper YAML::Syck

Or typing install followed by names of all the modules on the same line seperated by space on cpan prompt,

cpan> install PDF::API2 Text::CSV XML::Dumper YAML::Syck

Note: If somehow a module can't be installed using the cpan you can directly download the .tar.gz source file and install it manually.

Title - CPAN | Author - PunLib | Article ID - 00000000014 | Last Updated - 2012-04-25 09:20:22 | Keywords - CPAN, Comprehensive Perl Archive Network, Perl Modules,



Your Name:
Your Email:

© 2008-22 Punlib
All Rights Reserved ((Read Best View))