Perl is an extremely flexible programming language, and a number of programs exist that use it. One of its advantages is the availability of many modules that you can add to create new functionality in programs without writing the code yourself.
Programs take advantage of the code included in these modules, and programmers can concentrate on the code—and not worry about duplicating work. However, you must install any given module before the Perl program in question will run.
While a number of Linux vendors create RPM packages of various Perl modules, they don't create packages for every existing module—only what's required in their distribution. That's where the Comprehensive Perl Archive Network (CPAN) comes in.
Using the CPAN module, you can use Perl itself to install other modules. To do so, you need the name of the module you want to install. For example, let's say you want to install the Time::HiRes or DBI module. Typically, if you look at the README file for a given Perl program, it will list the names of any required modules.
To use CPAN, become the root user and execute the following:
# perl -MCPAN -e shell
The first time you do so, you must configure the CPAN module. Take a moment to answer the questions it asks; in most cases, pressing [Enter] for most questions is sufficient.
To install a module, type install and the name of the module at the CPAN prompt. For example:
cpan> install Time::HiRes
This downloads, compiles, and installs the Time::HiRes Perl module. For a full listing of the available CPAN modules, check out the CPAN Web site.