Wouldn't it make more sense to create (or open in append mode) but not add an entry in that case?
Personally, I'd handle the logging via the Log::Log4perl module and instead of your current usage sub, I'd write POD documentation and output that via the Pod::Usage module.
UPDATE: Here's a short example using Pod::Usage instead of your custom die SIG handler.
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() stateme
+nts 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<This program> will read the given input file(s) and do something
useful with the contents thereof.
=cut
|