Perl Modules and CPAN


The Unix philosophy of creating and using small programs that do one thing well, often in conjunction with other similar programs, has led to the largely modular design of even the most complicated applications. So it is with Perl. Perl does much of its work through modules that plug in to the Perl environment. Many Perl modules are installed with the basic Perl installation, and dozens more are optionally installable through YaST.

One important component included in the base Perl installation is the marvelous CPAN.pm module. CPAN.pm makes it easy to download and install other modules from CPAN, the Comprehensive Perl Archive Network. CPAN is a large repository of Perl modules, reusable code, and documentation. There you can find more Perl goodies than you can imagine.

CPAN is always accessible from the Web at http://www.cpan.org, and you can search and download modules directly with your browser. But for ease of installation, the Perl CPAN module can't be beat.

Log in as SuperUser and type

perl -MCPAN -e shell 

The first time you run CPAN, you'll go through a configuration dialog. Accepting the default configuration options is usually the right thing to do, but you'll still want to read through everything carefully. You can always modify the configuration later on if you have to by entering o conf init at the cpan> prompt.

After configuring your system, CPAN will ask about your location and find a nearby download mirror. This speeds up your transfer and doesn't use as much bandwidth. After you've selected one or more mirror sites, you will see the cpan> prompt. You can now search CPAN for something useful.

Let's look for an update for SpamAssassin. Type h to see a list of available commands. Reading the help screen, we see that regular expressions can be used to search for a specific module. To search for our updated package with the regular expression, spam, type

m /spam/ 

Tip

On each visit to the CPAN mirror, run reload index to ensure that you can access the latest modules to hit the mirror.


The CPAN module searches the database for modules that fit and then lists the matching modules. Among them is the Mail::SpamAssassin module (and several child modules). To download and install this module, type

install Mail::SpamAssassin 

CPAN will download the module, configure it for your system, and run make and make install all at once. If you prefer to download now and install later, use the get command instead of install. The h or ? command is always at your side to help you decide what to do next.

Tip

The CPAN module offers a command history if ReadLine support is enabled. If it is, you can use your up and down arrows to repeat or edit a recent command.


When you have found and installed all the modules you want, type q at the cpan> prompt to quit the module and return to the SuperUser prompt.



SUSE Linux 10 Unleashed
SUSE Linux 10.0 Unleashed
ISBN: 0672327260
EAN: 2147483647
Year: 2003
Pages: 332

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net