Matt, it really wasn't that hard

jdavidb on 2001-12-20T19:35:57

#!/usr/local/bin/perl5.6.1

# See matts's journal if you have no idea # what this is all about # Pudge, should I have to &lt; when I want to <?

use warnings; use strict;

unless (@ARGV) { die "If you don't specify a module name, you will have problems.\n"; }

my($MODNAME) = @ARGV;

my $topdirname = $MODNAME; $topdirname =~ s[::][-]g; mkdir($topdirname); chdir($topdirname); mkdir("t"); mkdir("lib"); my $moddirname = $MODNAME; $moddirname =~ s[::][/]g; mkdir_p("lib/$moddirname"); my $fh; foreach my $file (qw(README MANIFEST MANIFEST.SKIP Makefile.PL Changes)) { open($fh, ">$file"); } open($fh, ">lib/$moddirname.pm"); open($fh, ">t/00basic.t");

open($fh, ">Makefile.PL") || die "Can't open Makefile.PL: $!"; print $fh <<"EOF"; use ExtUtils::MakeMaker; WriteMakefile( 'NAME' => '$MODNAME', 'VERSION_FROM' => 'lib/$moddirname.pm', 'PREREQ_PM' => {}, 'ABSTRACT_FROM' => 'lib/$moddirname.pm', 'AUTHOR' => 'Matt Sergeant <matt\@sergeant.org>', ); EOF close($fh) || warn "Couldn't close Makefile.PL: $!";

open($fh, ">t/00basic.t") || die "Can't open t/00basic.t: $!"; print $fh <<"EOF"; use Test; BEGIN { plan tests => 1 } END { ok(\$loaded) } use $MODNAME; \$loaded++; EOF close($fh) || warn "Couldn't close t/00basic.t: $!";

open($fh, ">MANIFEST.SKIP") || die "Can't open MANIFEST.SKIP: $!"; print $fh <<'EOF'; CVS/.* \.bak$ \.sw[a-z]$ \.tar$ \.tgz$ \.tar\.gz$ ^mess/ ^tmp/ ^blib/ ^Makefile$ ^Makefile\.[a-z]+$ ^pm_to_blib$ ~$ EOF close($fh) || warn "Couldn't close MANIFEST.SKIP: $!";

# Just to be cute ;) exec("$ENV{EDITOR} lib/$moddirname.pm");

sub mkdir_p { my($directory) = @_; if (not mkdir($directory)) { use File::Basename qw(dirname); mkdir_p(dirname($directory)); mkdir($directory); } }