This is the template I use:
use strict;
use warnings;
use Getopt::Long qw(:config no_ignore_case);
use Pod::Usage;
my %opt;
my ( $opt_help, $opt_man );
GetOptions(
# 'add+' => \$opt{add},
# 'flag!' => \$opt{flag},
# 'integer=i' => \$opt{integer},
# 'optional:s' => \$opt{optional},
# 'string=s' => \$opt{string},
'help!' => \$opt_help,
'man!' => \$opt_man,
) or pod2usage( -verbose => 0 );
pod2usage( -verbose => 1 ) if defined $opt_help;
pod2usage( -verbose => 2 ) if defined $opt_man;
# Make sure at least one argument provided
if ( !@ARGV ) {
pod2usage( -verbose => 0, -message => "$0: one argument required\n
+" );
}
__END__
=head1 NAME
[TITLE] - [TEXT]
=head1 SYNOPSIS
[PROGNAME ARGS]
=head1 DESCRIPTION
[TEXT DESCRIPTION]
=head1 OPTIONS
[OPT DESCRIPTION]
--help Print Options and Arguments.
--man Print complete man page.
=head1 LICENSE
This software is released under the same terms as Perl itself.
If you don't know what that means visit L<http://perl.com/>.
=cut