Item Description: an h2xs replacement for non-XS modules
Review Synopsis:
ExtUtils::ModuleMaker is a replacement for h2xs. So what's wrong with h2xs anyway and how does ExtUtils::ModuleMaker perform any better?
My annoyances with h2xs (these are purely personal):
On reflection, these seem quite petty -- but I am very lazy.
This is more to type, and produces similar results to h2xs. However there are the following improvements:
The QuickModule() function still leaves A.U. Thor as the author of your work and other defaults and leaves you with only one module in your distribution. Use Generate_Module_Files() for a more complete solution...
Generate_Module_Files()
Here is my code using ExtUtils::ModuleMaker that allows me to be extra lazy:
#!/usr/bin/perl5.6.1 -w use strict; use Getopt::Long; use ExtUtils::ModuleMaker; my %author = ( NAME => 'Simon Flack', EMAIL => 'simonflk@example.com', CPANID => 'SIMONFLK', WEBSITE => 'http://www.simonflack.com', ); # Set some defaults my $license = 'perl'; my $version = '0.1'; my $module_name = ''; my $extra_modules = ''; my @extra_modules = (); GetOptions ( 'name=s' => \$module_name, 'version:f' => \$version, 'license:s' => \$license, 'extra:s'=> \$extra_modules ); Usage() unless $module_name; ###################################################################### +######### # Now make the module ###################################################################### +######### push @extra_modules, {NAME => $_, ABSTRACT => $_} for split /,/, $extra_modules; Generate_Module_Files ( NAME => $module_name, ABSTRACT => $module_name, AUTHOR => \%author, VERSION => $version, LICENSE => $license, EXTRA_MODULES => \@extra_modules, ); sub Usage { my ($prog) = $0 =~ /\/([^\/]+)$/; print <<HELP; $prog - Simple Module Maker Usage: $prog <-name ModuleName> [-version=?] [-extra=?,?] [-license=?] Eg: $prog -name My::Module $prog -name My::Module -version 0.11 -extra My::Utils,My::Extra -license perl HELP }
Now I can write: "newmodule -n Foo::Bar -v 1.0 -l gpl" and I can start coding and writing tests straight away...
Note: If you use this, don't forget to change the author info.
There aren't many.
See the following docs for more information about writing modules
update: h2xs compatibility
crazyinsomniac pointed out that h2xs has a backwards compatibility option "-b" I couldn't find this documented and it didn't work when I tried it (my v5.6.0 h2xs is higher up in the PATH than my 5.6.1 h2xs). It seems that is is a new option since perl5.6.1. I'll leave my original statement in here because it will still apply to some people on older perls. Thanks to crazyinsomniac for pointing out this option.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: ExtUtils::ModuleMaker
by Dog and Pony (Priest) on Jun 11, 2002 at 15:32 UTC | |
by ignatz (Vicar) on Jul 21, 2002 at 15:44 UTC | |
by dragonchild (Archbishop) on Oct 10, 2003 at 19:30 UTC | |
by mpd (Monk) on Aug 18, 2003 at 03:11 UTC | |
Re: ExtUtils::ModuleMaker
by geektron (Curate) on Feb 08, 2005 at 17:24 UTC | |
Re: ExtUtils::ModuleMaker
by xdg (Monsignor) on Mar 08, 2004 at 16:23 UTC | |
Re: ExtUtils::ModuleMaker
by bart (Canon) on Nov 18, 2006 at 15:20 UTC |