Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: MakeMaker, h2xs, and writing CPAN modules

by Ovid (Cardinal)
on Jun 24, 2002 at 05:10 UTC ( [id://176690]=note: print w/replies, xml ) Need Help??

in reply to MakeMaker, h2xs, and writing CPAN modules

What I understood you to ask was this: how do I create a distribution so that I can edit my module in place without having to install it? The docs aren't clear, but this is basically how this works. First, edit h2xs and change the $author and $email to your name and email address (otherwise, h2xs will write out spurious information for this and you'll have to edit the results). Then, do this:

  1. h2xs -AX -n Foo::Bar -v .01
  2. Copy your module to
  3. Fill out or, better yet, create a Foo/Bar/t/ directory and create tests there (be sure to update the MANIFEST)
  4. perl
  5. make
  6. make test
  7. make dist

It's the last step that makes a distribution for you!

Also note the -v argument to h2xs. That tells it what your version number is, so that's automatically created for you, if you're filling in the module manually as opposed to copying one that you've already made. You can skip this if you wish.

If, for some reason, your tests do not pass, be sure to run make clean, fix your module (and/or tests) and repeat the above steps, from step 4 (perl Makefile.PL), until the tests pass. If you fail to run make clean, any edits you make to Foo/ will not be picked up.

When you run make test, all tests will be run through the test harness, which will load your module from the blib directory that is created. Thus, there is no need to actually install the module.

Hope this helps.


Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

  • Comment on Re: MakeMaker, h2xs, and writing CPAN modules

Replies are listed 'Best First'.
Re: Re: MakeMaker, h2xs, and writing CPAN modules
by perrin (Chancellor) on Jun 24, 2002 at 05:37 UTC
    Okay, so you're saying the thing to do is write the module and then use h2xs just to help create the distribution? That sounds reasonable and is basically what I've ended up with, it's just that all of the docs make it sound like you should start with h2xs.

      You can write the module either before or after you use h2xs. I've done both. When the docs are so strident about using h2xs, they're primarily referring to using it for modules that you are going to distribute (see "How To Write a Makefile.PL" in perldoc ExtUtils::MakeMaker).

      If you've already written your module, then use h2xs, though to be frank, using this utility before you start to write the module is easier because the Test::Harness is all ready to go, thus writing tests and using make test is sooooo much simpler.


      Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://176690]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-23 16:58 GMT
Find Nodes?
    Voting Booth?

    No recent polls found