Linux

Install Perl modules using CPAN

21 Feb/10

If you’ve come across any software that requires Perl modules, you might have found yourself pulling out your hair, trying to figure out how to install those modules. You’ve tried downloading the source, only to find one dependency issue or another. You’ve searched Synaptic or gnome-packagekit high and low to come up empty handed.

What you may not know is there is a tool specifically designed to help you install Perl modules. The tool? CPAN. CPAN is the Comprehensive Perl Archive Network and contains a vast assortment of software, used by and with Perl, and makes for easy installation. Problem is, most people don’t know about CPAN or how to use it.

In this article I will introduce you to the CPAN tool and how it can be used to help you get all the Perl modules you need installed. NOTE: There will be times when CPAN has trouble installing modules. In those cases, the best bet is to download the source and read through the README file for better instructions. Generally speaking though, you should be able to get the majority of modules installed with this tool.

Installing CPAN

If you have Perl installed on your machine, you have CPAN. You can test this out by issuing the command cpan from the command line. If you get the dreaded command not found make sure you have:

  • perl
  • perl-base
  • perl-modules

installed. If one (or more) is missing, mark them for installation and then try the command again. When you have successfully reached the CPAN console your prompt will look like:

cpan[1]>

When you see that, you’re ready to rock.

Basic structure

The basic structure of cpan is simple. Once you’re at the command prompt you would issue a command similar to:

install MODULE::NAME

Where MODULE::NAME is the actual name of the module.

But when you first run CPAN the system will ask you a few easy questions. CPAN will want to check for a network connection and so on (hit Enter to accept all of the defaults).

First things

When you have first reached the CPAN prompt you might want to first install a couple of bundle packs that contain numerous modules. The very first install command you will enter is:

install Bundle::CPAN

The above command will install numerous modules, but it might also come up with some errors. Any time you receive an error in CPAN it will report the error to you in the console. Often times the error will point you in a direction that will help to resolve an issue. For example, running install Bundle::CPAN on a fresh install gives me:

Warning: prerequisite Compress::Raw::Zlib 2.024 not found. We have 2.008.
Writing Makefile for IO::Compress
Could not read '/root/.cpan/build/IO-Compress-2.024-1nwcFW/META.yml'. Falling back to other methods to determine prerequisites
---- Unsatisfied dependencies detected during ----
---- PMQS/IO-Compress-2.024.tar.gz ----
Compress::Raw::Zlib [requires]
Compress::Raw::Bzip2 [requires]
Shall I follow them and prepend them to the queue
of modules we are processing right now? [yes]

So, as you can see, CPAN is intelligently resolving your dependency issues for you. In a large install like Bundle:CPAN this can take quite some time.

How to know which module?

If you are trying to install a piece of software on Linux usually you are given a solid roadmap in either the README or INSTALL file with the source. Within that file will be listed any/all Perl modules necessary to meet the installation requirements. And now, with the help of CPAN, you can install them.

Final thoughts

Believe it or not, using CPAN is a simple process. From this easy to use console you can install all of the Perl modules you need. Of course, there is much more to CPAN than this. To find out how much more enter h at the CPAN console for the help file.

Continua a leggere – Original Link: Install Perl modules using CPAN

Technorati Tags: , , , , , , , , , , , , ,

Leggi Anche

Condividi
Condividi in DeliciousCondividi in DiggCondividi in RedditCondividi in StumbleCondividi in MixxCondividi in TecnoratiCondividi in Ok Notizie

Commenti

I commenti sono disabilitati per questo articolo.

I commenti sono chiusi.

Autore

    Spina Rosario
    Inserito da
Gestionale Immobiliare - Realizzazione Sito Web per Agenzia Immobiliare

Archivio

Iscrizione Newsletter

    Tieniti informato con tutte le novità del mondo informatico con la nostra newsletter
    Email:

    Nome:

    Auto Shop Italia
    Web Burning Blog
    Info Privacy

Meta