On Tuesday, September 30, 2003, at 06:14 PM, Andy Lester wrote:

At 5:09 PM -0500 9/30/03, Eric Lease Morgan wrote:
How do I create a standard Perl module intended for distribution?

Steal. Find a good distribution (say, MARC::Record) and adapt from there.


I never use h2xs any more.

I second that! I would start out this way: download a distribution by a CPAN author who's got a few modules under their belt (say, INGY or ABW or our own PETDANCE) and delete everything but the following:


  Changes
  lib/  (delete its contents)
  Makefile.PL
  MANIFEST.SKIP
  README
  t/    (delete its contents)

Whip up a dead simple module Foo in lib/Foo.pm, something like this:

  package Foo;
  use strict;
  use vars qw($VERSION);
  $VERSION = '0.01';
  sub new { bless {}, shift }
  sub bar { rand }

Whip up a dead simple test in t/bar.t:

  use Test::More tests => 5;
  use_ok( 'Foo' );
  my $foo = Foo->new;
  ok( $foo );
  isa_ok( $foo, 'Foo' );
  my $rand = $foo->bar;
  ok( $rand >= 0.0, 'greater than or equal to 0.0' );
  ok( $rand < 1.0,  'less than 1.0' );

Just something simple to help you get the right distribution details taken care of without having to deal with your modules themselves (yet).

Hack on MANIFEST.SKIP if you like -- for example, I'm running Mac OS X so I make sure the following line is in there (.DS_Store files have no meaning except on Mac OS X [and darwin generally?]):

\.DS_Store$

Hack on Makefile.PL (just delete anything that doesn't make sense), then do something like this:

  % perl Makefile.PL
  % make manifest
  % make distcheck
  % make skipcheck
  % perl Makefile.PL
  % make
  % make test

Once you've got `make' and `make test' running without errors, rewrite Changes and README, move in your modules, etc.

Reading material:

  http://www.cpan.org/modules/00modlist.long.html#Part1-Modules:C
  http://www.cpan.org/modules/04pause.html

Try googling for "my first CPAN module" and see what comes up -- there may be some good advice for new CPAN authors.
at some point
Also, you might want to look into Module::Build -- you can use it instead of, or in addition to, ExtUtils::MakeMaker.


HTH,

Paul.

--
Paul Hoffman :: Taubman Medical Library :: Univ. of Michigan
[EMAIL PROTECTED] :: [EMAIL PROTECTED] :: http://www.nkuitse.com/



Reply via email to