How to install a Perl Module in Linux?

There are various ways to download and install perl modules from CPAN. In general it’s a good idea to download and install the perl module but we will see the different ways of installing the perl module.

Method 1. The easiest way is to use the perl CPAN module. SSH to the server as root and execute:

# cpan

if you are running this for the first time, it will prompt you for a few questions (default answers are fine) before providing you with the “cpan >” prompt. To install a module, say for example “Perl::OSType”, execute

cpan > install Perl::OSType

this will download and compile the module and install it server wide. To know more commands/options of cpan, type question mark ( ? ) at the cpan prompt.

Method 2. The second and the quickest method is to use perl CPAN module from the bash prompt instead of ‘cpan’ prompt. If you are on the command line of Linux, just execute

# perl -MCPAN -e 'install Perl::OSType'

Method 3. The above 2 methods are the easiest one but it is recommended to install the module manually as the above methods may not always work.

Search and download the module from http://search.cpan.org/ and then wget it on your server. Once done, extract it:

# tar -zxf Perl-OSType-1.002.tar.gz

Untar the downloaded file and go to the extracted directory. There is a README file inside the directory with the installation steps, however, here are they:

# perl Makefile.PL 
# make 
# make test 
# make install

That is it.

This entry was posted on Saturday, April 30th, 2011 and is filed under Linux Administration. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

One Response to “How to install a Perl Module in Linux?”

  1. Gazduire web

    Exactly what i was looking for
    Thanks