Writing CPAN modules

it's easy: a how-to for beginners

This is an outline of one good way to do it:

• Get a PAUSE account.
Request a PAUSE Account
They'll ask what you plan to do with it.
• Pick a name for the module. It's good form to ask advice.
The traditional forum: comp.lang.perl.modules
• Run module-starter (off of CPAN, of course) to generate a framework to work with
Mainly, you tell it what, where, who and with what.
• Move your code into the generated framework,
Modules go in lib (create a script to put any scripts)
• Revise your Build.PL.
• To ship a script (e.g. "modular_script"), add this to Build.PL:
script_files => ['script/modular_script'],
• Write some tests if you haven't already.
• You develop in much the same way you would install a perl package (manually):
perl Build.PL
./Build test
• Before you create a cpan distribution, remember (ha!) to:
Update these files:
MANIFEST (important!)
And also:
Double-check your SYNOPSIS
Run a spell-checker on pod
• When you're ready to create a package:
./Build dist
./Build distcheck (not required, but a good idea)
• Back to PAUSE. Log-in, and upload the file:
Upload a file to CPAN
• Immediately after uploading, bump up $VERSION.
• Sit back for a while, and remember to check the smoke tests for your module here:
See? Easy enough.

CPAN build diagram

Next: it's hard: portability problems

Joseph Brenner, 22 Sep 2009