What is a CPAN Distribution

Unpack the mystery behind what’s in a CPAN distribution

Structure of a distribution

Each CPAN distribution is a gzipped tar archive with a filename consisting of distribution name and version. The distribution can contain one or more modules; the distribution name is then usually derived from its most important module.

For example the distribution of Path-Tiny is in an archive called Path-Tiny-0.072.tar.gz and consists of a single module Path::Tiny.

Inside a distribution are the following components:

A distribution usually has the following directory structure:

Sample-Distribution-0.1.0
.
├── lib
│   └── Sample
│       └── Distribution.pm
├── t
│   └── 00_my_first_test.t
├── README
├── Changes
├── LICENSE
├── Build.PL
├── MANIFEST
└── META.yml

Here, you can see the major components of a distribution:

There can be and usually are more files in a distribution, here we only described those which are in almost all distributions.

Further reading

The next section will show you how to create your own distribution.

See Neil Bowers’ A spotter’s guide to CPAN for detailed description of all files you can encounter in a distribution.

See Module::Build for detailed information about Build.PL script.

See ExtUtils::MakeMaker for detailed information about Makefile.PL script

See CPAN::Meta::Spec for detailed information about META.yml file format.