Writing CPAN modules
it's easy: a how-to for beginners
This is an outline of one good way to do it:
CPAN build diagram
- • 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.
- Dependencies for tests go in build_requires, all else in requires
- module-starter creates a build_requires,
but you need to add a requires entry
- List all your dependencies, even the core modules.
- Don't stress on required versions: 0 is usually okay.
- • 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.
it's hard: portability problems
22 Sep 2009