#! /usr/bin/perl -w # Create a new Perl script or module file use strict; use File::Basename; use File::Path; use Getopt::Std; our $opt_f; my ($fullPath, $path, $suffix); # Detect if no params given if(@ARGV == 0 || $ARGV[0] eq "--help") { print < 2008-01-19 usage: $0 [-f] FILE $0 --help switches: -f Force overwrite existing file --help This information. FILE is a string describing the new Perl script or module. Examples: Foo/Bar.pm Makes a file ./Foo/Bar.pm with package Foo::Bar in it foo.plx, foo Makes an executable script ./foo.plx or ./foo USAGE exit; } # Parse arguments getopts("f"); $fullPath = shift; (undef, $path, $suffix) = fileparse($fullPath, '\..*'); mkpath($path, 1) if(! -e $path); # Existing file? die "File $fullPath exists!\n" if(!$opt_f && -e $fullPath); my $standardUses = <$fullPath") or die "Can't open $fullPath: $!\n"; print OUTFILE <$fullPath") or die "Can't open $fullPath: $!\n"; print OUTFILE <