Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

jdavidb (1361)

jdavidb
  (email not shown publicly)
http://voiceofjohn.blogspot.com/

J. David Blackstone has a Bachelor of Science in Computer Science and Engineering and nine years of experience at a wireless telecommunications company, where he learned Perl and never looked back. J. David has an advantage in that he works really hard, he has a passion for writing good software, and he knows many of the world's best Perl programmers.

Journal of jdavidb (1361)

Thursday December 20, 2001
02:35 PM

Matt, it really wasn't that hard

[ #1743 ]

#!/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);
    }
}

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.