Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Best Module Starter?

by dynamo (Chaplain)
on Nov 09, 2007 at 04:04 UTC ( #649854=perlquestion: print w/ replies, xml ) Need Help??
dynamo has asked for the wisdom of the Perl Monks concerning the following question:

Greetings, fellow monks.

I come to you seeking advice to help choose a module starter system, specifically for production quality / CPAN-destined code. I'm especially interested in good or bad experiences, comparisons and reasons that one is good or bad. I'm just hoping to get a general sense of what the perlmonks crowd thinks, whether there is disagreement or consensus.

I'm aware of the following choices:

  • h2xs
  • ExtUtils::ModuleMaker
  • Module::Start
  • Module::Starter (which appears to have many plugins / modes, and is used in Acme::CreatingCPANModules)


I'm sure I've missed some, but I hope I get the point across. Please let me know if I've missed the Best one. What do you use? Why?

thank you

Comment on Best Module Starter?
Re: Best Module Starter?
by dragonchild (Archbishop) on Nov 09, 2007 at 04:15 UTC
    Find a distro you like and copy that. When I create a new one, I grab one I've already done and edit it.

    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
Re: Best Module Starter?
by brian_d_foy (Abbot) on Nov 09, 2007 at 04:27 UTC

    This is the topic of one of my TPJ columns: Making New Distributions.

    I use Template Toolkit. I create a directory of templates that do exactly what I want then process it with ttree. I can make the templates any way that I like without fooling with someone else's idea of what they should be, and my template cooker script can set any variables it likes so I don't have to specify those with the command.

    I've made it even easier since I wrote that article. I use it this like:

    prompt> module_cooker Foo::Bar

    Here's the code:

    #!/usr/bin/perl use Cwd; use File::Spec; my $module = $ARGV[0] || prompt( "Module name> " ); my $dist = $module; $dist =~ s/::/-/g; my $file = $module; $file =~ s/.*:://; $file .= ".pm"; my $cwd = File::Spec->catfile( cwd(), $dist ); system join " ", "/usr/local/bin/ttree" , "-s ~/.templates/modules" , "-d $cwd" , "-define module='$module'" , "-define module_file='$file'" , "-define module_dist='$dist'" ; chdir $dist; ( my $base = $module ) =~ s/.*:://; rename File::Spec->catfile( 'lib', 'Foo.pm' ), File::Spec->catfile( 'lib', $file ); sub prompt { print join "\n", @_; print "> "; my $line = <STDIN>; chomp $line; $line; }
    --
    brian d foy <brian@stonehenge.com>
    Subscribe to The Perl Review
      Thank you, this is a lot of good info to digest. I'm still considering how the rest of the template directory would look, as I'm a little rusty on my Template::Toolkit, but in the meantime, the article looks like a good start.

      Update - I like the approach, and in the long term I might want to adopt something similar myself, but at this point I don't have that template directory of exactly how I like everything.
      Thanks for the script. I changed it a bit. Here's my version. (Hopefully I didn't introduce a bug.)
      #!/usr/bin/perl # # a simple module initializer using TemplateToolkit # original source: http://www.perlmonks.org/?node_id=649856 # - code rewritten a bit # - use Path::Class instead of File::Spec # - renamed 'Foo.pm' template file to Module.pm use Cwd; use Path::Class qw(file); my $template_dir = "~/.templates/modules/"; my $module = $ARGV[0] || prompt( "Module name> " ); (my $dist = $module) =~ s/::/-/g; # Foo::Bar::Baz -> Foo-Bar-Baz (my $base = $module) =~ s/.*:://; # Foo::Bar::Baz -> Baz my $file = $base . ".pm"; # Baz -> Baz.pm my $cwd = file(cwd(), $dist); # must contain ttree (provided through Template Toolkit) $ENV{PATH} = '/usr/local/bin:/usr/bin:/bin'; my @command = ( 'ttree', "-s $template_dir", "-d $cwd", "-define module='$module'", "-define module_file='$file'", "-define module_dist='$dist'", ); system join " ", @command; chdir $dist; rename file('lib', 'Module.pm'), file('lib', $file); sub prompt { print join "\n", @_; print "> "; my $line = <STDIN>; chomp $line; $line; }
Re: Best Module Starter?
by absolut.todd (Monk) on Nov 09, 2007 at 06:04 UTC
      It's looking like the consensus is Module::Starter for those just starting out (pun intended) but then as you're no longer a beginner at beginning, and have your own specific preferences, the template toolkit approach looks better. Thank you (and all others who suggested Module::Starter)
Re: Best Module Starter?
by eyepopslikeamosquito (Canon) on Nov 09, 2007 at 07:18 UTC

    I've used both Module::Starter and the dragonchild approach of copying and editing an existing module you're happy with ... and been satisfied with both approaches.

    For a list of references on creating CPAN modules, see: Re: Finally a first version of my Module! Questions... (I find myself updating this list every time this sort of question gets asked here :-).

Re: Best Module Starter?
by talexb (Canon) on Nov 09, 2007 at 15:12 UTC

    Great question. When Andy Lester was in Toronto a few months back, he demoed Module::Starter for me at the pub afterwards, and it was very slick. I haven't used it yet, because I'm still at the point of learning and using Test Driven Development, progressing from Test::More to using prove with Test::Harness. (There's the additional challenge of fiddling with subversion for version control -- requires effort, but definitely worth it.)

    I'll continue to learn all of that good stuff, once I've got it well under control, I'll move to Module::Starter, and the stuff that I understand by then will be taken care of for me.

    Alex / talexb / Toronto

    "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Re: Best Module Starter?
by pemungkah (Priest) on Nov 09, 2007 at 23:14 UTC
    I too prefer Module::Starter. Here at Yahoo! we have some special things we need to do to get the code on our distribution server; with Module::Starter, it was easy enough to subclass the base class (actually I subclassed Module::Starter::PBP) and add in our special hooks in Makefile.PL and templates for other files we need for our distribution stuff.

    brian's Template Toolkit approach is way nicer as far as building files goes, and it might be a very fruitful idea for someone to try cross-pollinating Module::Starter and Template Toolkit to see if it would make it even easier to customize.

    I think for most people either Module::Starter or Module::Starter::PBP will be good enough to get going. If you find there are things that you simply cannot deal with as far as what's assumed as the default, then customizing is easy enough to do that you can at least consider doing it.

      I appreciate the bit of info that it's not hard to customize, as well as that Yahoo uses it at least a bit. I'm definintely going to try starting with Module::Starter::PBP and go from there.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://649854]
Approved by brian_d_foy
Front-paged by brian_d_foy
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2014-04-18 11:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (466 votes), past polls