in reply to Use a standard module or a "better" one, and how to make installing it troublefree.

I find Test is quite adequate. If you want you can bundle a copy of Test::More or even Test::Lincoln::Stein in your distro to avoid this problem. Asking permission for Test::More would be politic. See the CGI distribution to see Lincoln Stein roll his own test suite and include it. If you want complex tests you can have them just using Test:

use Test; BEGIN { plan tests => 42 } use Widget; ok(1) # module loaded OK my $w = new Widget; $reply = $w->method; @reply = $w->method; ok( $reply ); ok( @reply ); ok( $reply =~ m/something/ ); ok( $reply eq 'some string' ); ok( scalar @reply == 42 ); ok( join '', @reply eq 'some list of stuff' );

When you make a disto start like this:

$ h2xs -X Foo::Bar

This will write module stubs for you automatically. You will get:

Foo/Bar/Makefile.PL Foo/Bar/Bar.pm Foo/Bar/Changes Foo/Bar/test.pl Foo/Bar/MANIFEST Foo/Bar/README

You should then rename the Bar direcory Foo-Bar-0.01 if you want to follow the norms. You throw away the Foo dir :-) This writes you the stubs of your code which you can then just edit! Note if you just h2xs -X Bar then you will avoid generating the extra directory but you will need to edit your Makefile.PL it will have:

'NAME' => 'Bar' # but you need 'NAME' => 'Foo::Bar'

Package like this:

$ tar -cf Foo-Bar-0.01.tar Foo-Bar-0.01 $ gzip Foo-Bar-0.01.tar

Test like this:

$ tar -xzvf Foo-Bar-0.01.tar.gz $ perl Makefile.PL $ make $ make test $ make install

You will find that when you are playing with your distro you will repeat a number of steps over and over. I have a little script called make_manifest.pl which does a whole lot of things like:

You can get a copy of the script from the CGI::Simple distro (it expects to be in the misc/ dir which is where you will find it. Don't forget the CSS if you use this script.

Finally use Carp; see Carp for why and use the carp() and croak methods instead of warn() and die() which will put these messages in the perspective of the caller rather than the module.

Good luck.

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

  • Comment on Re: Use a standard module or a "better" one, and how to make installing it troublefree.
  • Select or Download Code

Replies are listed 'Best First'.
Re: Re: Use a standard module or a "better" one, and how to make installing it troublefree.
by Dog and Pony (Priest) on Apr 14, 2002 at 20:18 UTC
    First off, I do know that I can accomplish the same things with Test, even though I like the richer interface of Test::More better, and it makes the tests easier to read. A matter of taste, and "do I need it", and probably other things too. :)

    That said, I am impressed by the richness of your response, and I see that there are lots of gold here for when modules should start hitting the world. Thanks! Lots of it is not new, but it is a good summary, in good context.

    I guess I could bundle whatever module I need like that, but I think I would rather have it as a prerequisite, or use one that the installer is sure to have.

    And I will take a look at that script - no use in reinventing the wheel on that one. :)

    Again, thank you. I will have use for this. :)


    You have moved into a dark place.
    It is pitch black. You are likely to be eaten by a grue.