Wednesday, January 25, 2012

Notes on making a module distribution for CPAN

These notes are for creating a Perl CPAN module using Module::Build with some help from Module::Starter. I chose to use Module::Build because it is newer and was created to resolve various problems with the older ExtUtils::MakeMaker. The maintainer of ExtUtils::MakeMaker recommends using Module::Build.

Execute module-starter:

module-starter --mb --module=My::Module --author="Author Name" --email=author@email.com

Options used:

  • --mb - The build system to use. This is shorthand for --builder=Module::Build.
  • --module=My::Module - The name of the module that you want to build. A folder named My-Module will be created based on this.
  • --author="Author Name" - The name of the module author. The author, as well as the copyright and licensing, will be under this name in the README file and POD documentation.
  • --email=author@email.com - The author's email address

The following files are created:

  • Build.PL - Used to generate the Build script for this module. Under build_requires, you should add any other modules which this depends on. (This is a hash mapping from the module name to the required module version or 0 if no version is specified.)
  • Changes - A log of changes to this module. This is for the module maintainer to update with each version. You should modify the log entry for the initial version.
  • ignore.txt - An ignore file for your SCM.
  • lib/My/Module.pm - The module code, in the lib directory, with the folder structure following the module namespace structure. This should include the module version number and POD documentation (preferably after __END__.
  • MANIFEST - Lists the files contained in this distribution.
  • README - Provides an introduction to the module, as well as information about installation, documentation and licensing.
  • t/*.t - Various test files in which you will need to add your own unit tests.

No comments:

Post a Comment