NAME

CPAN - query, download and build perl modules from CPAN sites

SYNOPSIS

Interactive mode:

perl -MCPAN -e shell;

Batch mode:

use CPAN;

bundle, bundles, expand, install, make, test

DESCRIPTION

The CPAN module is designed to automate the fetching and, optionally, the building and installing of perl modules and extensions.

Modules are fetched from one or more of the mirrored CPAN (Comprehensive Perl Archive Network) sites and unpacked in a dedicated directory.

The CPAN module also supports the concept of named and versioned 'bundles' of modules. Bundles simplify the handling of sets of related modules. See BUNDLES below.

The package contains a session manager and a cache manager. There is no status retained between sessions. The session manager keeps track of what has been fetched, built and installed in the current session and will nor redo a 'make' or a 'install'. 'test' can be run repeatedly.

Interactive Mode

The interactive mode is entered by running

perl -MCPAN -e shell

which puts you into a readline interface. You will have most fun if you install Term::ReadKey and Term::ReadLine soon. That will give you both history and completion.

Once you're on the command line, type 'h' and the rest should be self-explanatory.

Cache Manager

Currently the cache manager only keeps track of the build directory ($CPAN::Config->{build_dir}). It is a simple FIFO mechanism that deletes complete directories below build_dir as soon as the size of all directories there gets bigger than $CPAN::Config->{build_cache} (in MB).

There is another directory ($CPAN::Config->{keep_source_where}) where the original distribution files are kept. This directory is not covered by the cache manager and must be controlled by the user. If you choose to have the same directory as build_dir and as keep_source_where directory, then your sources will be deleted with the same fifo mechanism.

Prerequisites

If you have a local mirror of CPAN and can access all files with "file:" URLs, then you only need perl5.003 to run this module. Otherwise you need Net::FTP intalled. LWP may be required for non-UNIX systems.

This module presumes that all packages on CPAN

  • Declare their $VERSION variable in an easy to parse manner. This prerequisite can hardly be relaxed because it consumes by far too much memory to load all packages into a single program just to determine the $VERSION variable . Currently all programs that are dealing with VERSION use something like this (requires MakeMaker-5.38, but don't bother if you don't have it):

    perl -MExtUtils::MakeMaker -le \
        'print MM->parse_version($ARGV[0])' filename

    If you are author of a package and wonder if your VERSION can be parsed, please try the above method.

  • come as compressed or gzipped tarfiles or as zip files,

Bundles

A bundle is just a perl module in the namespace Bundle:: that does not define any functions or methods. It usually only contains documentation.

It starts like a perl module with a package declaration and a $VERSION variable. After that the pod section looks like any other pod with the only difference, that one pod section exists starting with (verbatim):

=head1 CONTENTS

In this pod section each line obeys the format

Module_Name [Version_String] [- optional text]

The only required part is the first field, the name of a module (eg. Foo::Bar, ie. not the name of the distribution file). The rest of the line is optional. The comment part is delimited by a dash just as in the man page header.

The distribution of a bundle should follow the same convention as other distributions. The bundle() function in the CPAN module simply parses the module that defines the bundle and returns the module names that are listed in the described CONTENTS section.

Bundles are treated specially in the CPAN package. If you say 'install Bundle::Tkkit' (assuming such a bundle exists), CPAN will install all the modules in the CONTENTS section of the pod. See the Bundle::PleaseIgnore on CPAN. I wrote it as a blueprint for other bundles. You can install your own Bundles locally by placing a placing a conformant Bundle file somewhere into your @INC path.

CONFIGURATION

When the CPAN module is installed a site wide configuration file is created as CPAN/Config.pm. The default values defined there can be overridden in another configuration file: CPAN/MyConfig.pm. You can store this file in $HOME/.cpan/CPAN/MyConfig.pm if you want, because $HOME/.cpan is added to the search path of the CPAN module before the use() or require() statements.

Currently the following keys in the hash reference $CPAN::Config are defined:

build_cache       size of cache for directories to build modules
build_dir         locally accessible directory to build modules
cache_expire      after how many days refetch index files
cpan_home         local directory reserved for this package
gzip		    location of external program gzip
keep_source       keep the source in a local directory?
keep_source_where where keep the source (if we do)
make              location of external program make
make_arg	    arguments that should always be passed to 'make'
make_install_arg  same as make_arg for 'make install'
makepl_arg	    arguments passed to 'perl Makefile.PL'
more              location of external program more (or any pager)
tar               location of external program tar
unzip             location of external program unzip
urllist	    arrayref to nearby CPAN sites (or equivalent locations)

SECURITY

There's no security layer in the alpha version of CPAN.pm. CPAN.pm helps you to install foreign, unmasked, unsigned code on your machine. It's not different than when you do that on your own, but you should be warned now.

EXPORT

All functions in package CPAN are exported. The reason for this is that the primary use is intended for the cpan-shell or for one-liners.

Debugging

In interactive mode you can try "o debug" which will list options for debugging the various parts of the package. The output may not be very useful for you as it's just a byproduct of my own testing, but if you have an idea which part of the package may have a bug, it's certainly worth to give it a try and send me more specific output.

BUGS

Memory consumption is too high.

Not really a bug, but worth to mention: CPAN doesn't check if a module that is available in the path can really be require()d cleanly. Instead the module is parsed and the $VERSION variable is evaluated. Once that is done, the parsing stops and no further actions are taken. The reason for this is, that big bundles would cause a huge memory consumption just to check for the version.

AUTHOR

Andreas König <a.koenig@mind.de>

SEE ALSO

perl(1)

1 POD Error

The following errors were encountered while parsing the POD:

Around line 1696:

Non-ASCII character seen before =encoding in 'König'. Assuming CP1252