contents
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.
- https://pause.perl.org/pause/
- 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
- ./Build test
- • Before you create a cpan distribution, remember (ha!) to:
- Update these files:
- MANIFEST (important!)
- Changes
- README
- And also:
- Double-check your SYNOPSIS
- Run a spell-checker on pod
- podchecker
- perlcritic
- • 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:
- https://pause.perl.org/pause/authenquery
- 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:
- http://static.cpantesters.org
- See? Easy enough.
CPAN build diagram
Next:
it's hard: portability problems
Joseph Brenner,
22 Sep 2009