#!/usr/bin/env perl use Getopt::Long; $NAME ||= 'AUTHOR_NAME'; $EMAIL ||= 'AUTHOR_EMAIL'; $LICENSE ||= 'perl'; $KWALITEE = 0; sub usage { print STDERR <<'EOS'; Usage: newmod.pl [options] Module::Name --name X Use author name X. --email X Use author email X. --license X Use license X (e.g. "perl"). --kwalitee Add boilerplate to increase kwalitee. EOS exit 1; } @orig_argv = @ARGV; GetOptions('name:s' => \$NAME, 'email:s' => \$EMAIL, 'license:s' => \$LICENSE 'kwalitee' => \$KWALITEE) && @ARGV == 1 or usage; $mod = shift; ($dir = $mod) =~ s/::/-/g; mkdir $dir or die $!; chdir $dir; sub cat { my $o = shift; open OUT, ">$o" or die $!; print OUT @_; close OUT; } ($file = $mod) =~ s/.*:://; (undef, undef, undef, $d, $m, $y) = localtime; $y += 1900; $license = { perl => <<'EOS', This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. EOS gpl => <<'EOS', This library is free software under the terms of the GNU general public license. EOS }->{lc $LICENSE} || ''; cat 'Makefile.PL', < '$mod', VERSION_FROM => '$file.pm', PREREQ_PM => { }, (\$] >= 5.005 ? ## Add these new keywords supported since 5.005 (AUTHOR => q|$NAME <$EMAIL>|) : ()), ABSTRACT => 'Something.', ); EOS cat "$file.pm", <${EMAIL}E Bug reports welcome, patches even more welcome. =head1 COPYRIGHT Copyright (C) $y, $NAME. $license =cut EOS cat "test.pl", < 1; use $mod; ok(1, 'loaded'); EOS cat "ChangeLog", < * original version; created by $0 @orig_argv EOS cat "README", <