SPUG:module templates from h2xs
sthoenna at efn.org
Wed Feb 19 17:35:06 CST 2003
At the intersection of the two talks on pod and working with perl that
we heard is the issue of templates for a new module.
Perl includes the h2xs script to generate templates, complete with
sample POD, use strict and warnings, all the Exporter goop, etc.
h2xs was originally intended to create a wrapper xs module for a given
library header file, but with the -X option it will build a template
for a non-xs module.
For instance, try:
h2xs -X -n Foo
This creates a Foo directory with Foo.pm, a Makefile.PL, README, MANIFEST,
Changes, and even a test t/1.t.
If you need your module to work on older perl versions, use the -b
switch: h2xs -X -n Foo -b5.0.0. This will change the "use 5.008" (or
whatever perl version you are using) to "use 5.000" (or whatever you
said for -b). If you specify a version below 5.6, it puts in a "use
vars" line instead of using our, and removes the "use warnings". The
test file will also use Test::More instead of Test with a sufficiently
high backward compatibility version (or you can force it to always use
Test with --use-old-tests, or force it to use Test::More, adding that
as a prerequisite in Makefile.PL if needed, with --use-new-tests).
If you don't want AutoLoader, say -A.
If you want a HISTORY pod section instead of a separate Changes file,
Other options that apply even for non-xs modules are:
-B, -O, -P, -d, --skip-exporter, --skip-strict, --skip-warnings, -v,
and, of course, -h.
More information about the spug-list