use strict; use warnings; use Getopt::Long qw(:config no_ignore_case bundling); use Pod::Usage; my $VERSION = "2.0.0"; # Check Flags my $help; my $man; my $version; my $config; GetOptions ( 'h|help' => \$help, 'm|man' => \$man, 'V|VER' => \$version, 'c|config=s' => \$config, ) or pod2usage(2); pod2usage(1) if $help; pod2usage(-verbose => 2) if $man; pod2usage( { -message => "Version: $VERSION\n" }) if $version; # I forgot to include the open call when I posted this update # This open call won't execute if any of the above pod2usage() statements get executed. open( my $log_fh, '>', "SCRIPTLOG_FILE") or die ("Can't open SCRIPTLOG_FILE: $!\n"); # note that I used a lexical filehandle and the 3 arg form of open __END__ =head1 NAME sample - Using GetOpt::Long and Pod::Usage =head1 SYNOPSIS sample [options] [file ...] Options: -help brief help message -man full documentation =head1 OPTIONS =over 4 =item B<-help> Print a brief help message and exits. =item B<-man> Prints the manual page and exits. =back =head1 DESCRIPTION B will read the given input file(s) and do something useful with the contents thereof. =cut