Created
January 4, 2011 15:57
-
-
Save cou929/764953 to your computer and use it in GitHub Desktop.
Generate template of perl script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/perl | |
use strict; | |
use warnings; | |
&main; exit; | |
sub main { | |
if (!$ARGV[0]) { | |
print "Usage: $0 <script name>\n"; | |
} else { | |
print <<"END_SCRIPT"; | |
#! /usr/bin/perl | |
use strict; | |
use warnings; | |
use Getopt::Long; | |
use Pod::Usage; | |
my \$help = 0; | |
my \$man = 0; | |
GetOptions( | |
'help|h' => \\\$help, | |
'man' => \\\$man | |
) or pod2usage(); | |
pod2usage(1) if \$help; | |
pod2usage(-exitstatus => 0, -verbose => 2) if \$man; | |
&main; exit; | |
sub main { | |
} | |
__END__ | |
=head1 NAME | |
$ARGV[0] - Write short description of this script here | |
=head1 SYNOPSIS | |
$ARGV[0] [options] [file ...] | |
Options: | |
-help brief help message | |
-man full documentation | |
=head1 OPTIONS | |
=over 2 | |
=item B<-help> | |
Print a brief help message and exits. | |
=item B<-man> | |
Prints the manual page and exits. | |
=back | |
=head1 DESCRIPTION | |
B<This program> will read the given input file(s) and do something | |
useful with the contents thereof. | |
=cut | |
END_SCRIPT | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment