
The CPAN
Author: John M. Gabriele | back to index
---
Overview
There's a Perl standard libary module called CPAN. It's actually
been superceded as of late by the CPANPLUS module.
There is also the Comprehensive Perl Archive Network, aka, The CPAN.
When users speak of this, they sometimes refer to it as "the CPAN" to
distinguish it from the module of the same name. Another option is
to write the CPAN module as "CPAN.pm".
The CPAN is vast. Sam Tregar has noted:
"CPAN is my programming language of choice, the rest is just syntax."
Due to its size, scope, maturity, and ease of use, you'll find that there is very often a module in the CPAN to help you with whatever problem you happen to be working on.
Terminology
A few terms relating to things found in the CPAN:
Module
- A regular Perl module (a file that ends in "
.pm") Distribution
- When one or more modules are
tar.gz'd up together with the accompanyingREADME,Build.PL(orMakefile.PL), tests, etc. -- that's a distribution. Distribution file
- The
.tar.gzfile that a given distribution is packed into. The name of the distribution file does not necessarily have to correspond to the module or modules it contains, but usually does. Chapter or Category
- When an author uploads a distribution to CPAN, they may choose a chapterid to associate with the distribution. That group of categories that are listed at search.cpan.org are all the chapters that the CPAN knows about. That same list shows up when you look at modules on CPAN by-category.
Package
- A namespaces where the names in a given module
live. You declare the package name at the top of your module, with a
line that looks like
package Foo::Bar;. Register Namespace
- This is something a module/distribution author does after they upload their distribution file to CPAN. It's for registering the module in the module list. This way, the module shows up in the "by-module" and "by-category" listings on CPAN.
Bundle
CPANPLUSknows about "Bundles". As the CPAN docs describe, Bundles are just modules that list their dependencies in a simple but crude way so thatCPANPLUScan understand. If you install the bundle, you get all its listed dependencies too. It makes installing larger collections of related modules easier, but Bundles have now been superceded by Tasks.Task
- Successor to Bundle. Rather than using the magic
convention for naming dependencies like Bundle does, Tasks put the
dependencies right into a
Build.PLfile (or makefile) soCPANPLUShandles them just like other modules. See the docs for theTaskmodule on CPAN. Don't use Bundles anymore -- use Tasks instead.
Dependencies / Prerequisites
Dependencies for a distribution (modules that the distribution
needs to be already installed) get specified in the Build.PL
(or Makefile.PL) file. CPANPLUS can determine what module
distributions it needs to install to fulfill these prerequisites.
Module and Distribution names
It's most common for a distribution to contain one main module,
possibly with one or more sub-modules. If the main module is
Foo::Bar, the distribution file is typically named
"Foo-Bar-n.m.o.tar.gz", where n, m, and o
represent revision, version, and subversion numbers, respectively.