specify a minimum perl version with the -b option.
Writing $name/ppport.h
-Writing $name/$name.pm
+Writing $name/lib/$name.pm
Writing $name/$name.xs
Writing $name/fallback/const-c.inc
Writing $name/fallback/const-xs.inc
Writing $name/Makefile.PL
Writing $name/README
-Writing $name/t/1.t
+Writing $name/t/$name.t
Writing $name/Changes
Writing $name/MANIFEST
EOXSFILES
"-f -n $name -b $thisversion", $], <<"EOXSFILES",
Writing $name/ppport.h
-Writing $name/$name.pm
+Writing $name/lib/$name.pm
Writing $name/$name.xs
Writing $name/fallback/const-c.inc
Writing $name/fallback/const-xs.inc
Writing $name/Makefile.PL
Writing $name/README
-Writing $name/t/1.t
+Writing $name/t/$name.t
Writing $name/Changes
Writing $name/MANIFEST
EOXSFILES
"-f -n $name -b 5.6.1", "5.006001", <<"EOXSFILES",
Writing $name/ppport.h
-Writing $name/$name.pm
+Writing $name/lib/$name.pm
Writing $name/$name.xs
Writing $name/fallback/const-c.inc
Writing $name/fallback/const-xs.inc
Writing $name/Makefile.PL
Writing $name/README
-Writing $name/t/1.t
+Writing $name/t/$name.t
Writing $name/Changes
Writing $name/MANIFEST
EOXSFILES
"-f -n $name -b 5.5.3", "5.00503", <<"EOXSFILES",
Writing $name/ppport.h
-Writing $name/$name.pm
+Writing $name/lib/$name.pm
Writing $name/$name.xs
Writing $name/fallback/const-c.inc
Writing $name/fallback/const-xs.inc
Writing $name/Makefile.PL
Writing $name/README
-Writing $name/t/1.t
+Writing $name/t/$name.t
Writing $name/Changes
Writing $name/MANIFEST
EOXSFILES
"\"-X\" -f -n $name -b $thisversion", $], <<"EONOXSFILES",
-Writing $name/$name.pm
+Writing $name/lib/$name.pm
Writing $name/Makefile.PL
Writing $name/README
-Writing $name/t/1.t
+Writing $name/t/$name.t
Writing $name/Changes
Writing $name/MANIFEST
EONOXSFILES
"-f -n $name $header -b $thisversion", $], <<"EOXSFILES",
Writing $name/ppport.h
-Writing $name/$name.pm
+Writing $name/lib/$name.pm
Writing $name/$name.xs
Writing $name/fallback/const-c.inc
Writing $name/fallback/const-xs.inc
Writing $name/Makefile.PL
Writing $name/README
-Writing $name/t/1.t
+Writing $name/t/$name.t
Writing $name/Changes
Writing $name/MANIFEST
EOXSFILES
my $total_tests = 3; # opening, closing and deleting the header file.
for (my $i = $#tests; $i > 0; $i-=3) {
# 1 test for running it, 1 test for the expected result, and 1 for each file
- # plus 1 to open and 1 to check for the use in $name.pm and Makefile.PL
+ # plus 1 to open and 1 to check for the use in lib/$name.pm and Makefile.PL
# And 1 more for our check for "bonus" files, 2 more for ExtUtil::Manifest.
# use the () to force list context and hence count the number of matches.
$total_tests += 9 + (() = $tests[$i] =~ /(Writing)/sg);
pop @INC;
chdir ($up) or die "chdir $up failed: $!";
- foreach my $leaf ("$name.pm", 'Makefile.PL') {
+ foreach my $leaf (File::Spec->catfile('lib', "$name.pm"), 'Makefile.PL') {
my $file = File::Spec->catfile($name, $leaf);
if (ok (open (FILE, $file), "open $file")) {
my $match = qr/use $version;/;
$Text::Wrap::columns = 80;
use ExtUtils::Constant qw (WriteConstants WriteMakefileSnippet autoload);
use File::Compare;
+use File::Path;
sub usage {
warn "@_\n" if @_;
# Save current directory so that C::Scan can use it
my $cwd = File::Spec->rel2abs( File::Spec->curdir );
-my ($ext, $nested, @modparts, $modfname, $modpname);
# As Ilya suggested, use a name that contains - and then it can't clash with
# the names of any packages. A directory 'fallback' will clash with any
# new pragmata down the fallback:: tree, but that seems unlikely.
my $constsxsfname = 'const-xs.inc';
my $fallbackdirname = 'fallback';
-$ext = chdir 'ext' ? 'ext/' : '';
-
-if( $module =~ /::/ ){
- $nested = 1;
- @modparts = split(/::/,$module);
- $modfname = $modparts[-1];
- $modpname = join('/',@modparts);
-}
-else {
- $nested = 0;
- @modparts = ();
- $modfname = $modpname = $module;
-}
-
-
+my $ext = chdir 'ext' ? 'ext/' : '';
+
+my @modparts = split(/::/,$module);
+my $modpname = join('-', @modparts);
+my $modfname = pop @modparts;
+my $modpmdir = join '/', 'lib', @modparts;
+my $modpmname = join '/', $modpmdir, $modfname.'.pm';
+
if ($opt_O) {
warn "Overwriting existing $ext$modpname!!!\n" if -e $modpname;
}
else {
die "Won't overwrite existing $ext$modpname\n" if -e $modpname;
}
-if( $nested ){
- my $modpath = "";
- foreach (@modparts){
- -d "$modpath$_" || mkdir("$modpath$_", 0777);
- $modpath .= "$_/";
- }
-}
--d "$modpname" || mkdir($modpname, 0777);
+-d "$modpname" || mkpath([$modpname], 0, 0775);
chdir($modpname) || die "Can't chdir $ext$modpname: $!\n";
my %types_seen;
}
my @const_names = sort keys %const_names;
-open(PM, ">$modfname.pm") || die "Can't create $ext$modpname/$modfname.pm: $!\n";
+-d $modpmdir || mkpath([$modpmdir], 0, 0775);
+open(PM, ">$modpmname") || die "Can't create $ext$modpname/$modpmname: $!\n";
$" = "\n\t";
-warn "Writing $ext$modpname/$modfname.pm\n";
+warn "Writing $ext$modpname/$modpmname\n";
print PM <<"END";
package $module;
# the contents of the Makefile that is written.
WriteMakefile(
NAME => '$module',
- VERSION_FROM => '$modfname.pm', # finds \$VERSION
+ VERSION_FROM => '$modpmname', # finds \$VERSION
PREREQ_PM => {$prereq_pm}, # e.g., Module::Name => 1.1
(\$] >= 5.005 ? ## Add these new keywords supported since 5.005
- (ABSTRACT_FROM => '$modfname.pm', # retrieve abstract from module
+ (ABSTRACT_FROM => '$modpmname', # retrieve abstract from module
AUTHOR => '$author <$email>') : ()),
END
if (!$opt_X) { # print C stuff, unless XS is disabled
close(RM) || die "Can't close $ext$modpname/README: $!\n";
my $testdir = "t";
-my $testfile = "$testdir/1.t";
+my $testfile = "$testdir/$modpname.t";
unless (-d "$testdir") {
mkdir "$testdir" or die "Cannot mkdir $testdir: $!\n";
}
print EX <<_END_;
# Before `make install' is performed this script should be runnable with
-# `make test'. After `make install' it should work as `perl 1.t'
+# `make test'. After `make install' it should work as `perl $modpname.t'
#########################
warn "Writing $ext$modpname/MANIFEST\n";
open(MANI,'>MANIFEST') or die "Can't create MANIFEST: $!";
-my @files = grep { -f } (<*>, <t/*>, <$fallbackdirname/*>);
+my @files = grep { -f } (<*>, <t/*>, <$fallbackdirname/*>, <$modpmdir/*>);
if (!@files) {
eval {opendir(D,'.');};
unless ($@) { @files = readdir(D); closedir(D); }