In this article we will cover the basics of installing perl modules with perl-CPAN.

Prerequisite

You will need to have GNU C Compiler installed on your system.  It can be installed by running the following command:

yum -y install gcc

Installing Software

We need to install perl-CPAN with the following command:

yum -y install perl-CPAN

Configure CPAN

Now that we have perl-CPAN installed, we now have to configure it, or better yet, let it configure itself.

cpan

Example output:

CPAN is the world-wide archive of perl resources. It consists of about 300 sites that all replicate the same contents around the globe. Many countries have at least one CPAN site already. The resources found on CPAN are easily accessible with the CPAN.pm module. If you want to use CPAN.pm, lots of things have to be configured. Fortunately, most of them can be determined automatically. If you prefer the automatic configuration, answer 'yes' below.
If you prefer to enter a dialog instead, you can answer 'no' to this question and I'll let you configure in small steps one thing after the other. (Note: you can revisit this dialog anytime later by typing 'o conf init' at the cpan prompt.)
Would you like me to configure as much as possible automatically? [yes]

Hitting enter will tell cpan to try to configure itself. (So hit enter)

The screen will scroll with a lot of information, then you will be presented with the following prompt (if all went well)

cpan[1]>

Using CPAN

This is the cpan shell prompt.  .

cpan[1]>

From here it is simple to install all your perl modules.  For this example we will install Term::ReadKey which is a small module that allows you to hide passwords typed on the command line in perl scripts.

At the cpan prompt (cpan[1]> )type the following:

cpan[1]> install Term::ReadKey

CPAN will now fetch the necessary files and install them for you.

Troubleshooting

Some people have reported issues when using a proxy server.  The simplest way around this is to export the http_proxy variable as root.

For more information on http_proxy and how to set the variable, see "How to Set the http_proxy Variable in Linux".