in reply to Re: INIT {$SIG{__DIE__} and Getopt::Long
in thread INIT {$SIG{__DIE__} and Getopt::Long

Hi, placing it after does not fix it completely but it is better:
G:\development\bin>x.pl -l > 4,GENERAL,Script warning: Unknown option: l print() on unopened filehandle LOG at G:\development\bin\x.pl line 45. Version:2.0.0 NAME xxx G:\development\bin>

However using INIT for the option seems to do what I am looking for.

Example:
G:\development\bin>x.pl -b Unknown option: b Version:2.0.0 NAME xxx G:\development\bin>
Code:
use strict; use warnings; use Getopt::Long qw(:config no_ignore_case bundling); # Get options / my $VERSION ; my $flag_help; my $flag_version; my $flag_config; INIT { $VERSION = "2.0.0"; GetOptions ( 'h|help' => \$flag_help, 'V|VER' => \$flag_version, 'c|config=s' => \$flag_config, ) or die USAGE(); # Check flags and print usage if ($flag_version) { print "Version: $VERSION\n"; exit; } if ($flag_help) { USAGE(); exit; } } INIT {$SIG{__DIE__}=sub {LOG_MSG("normal",3,"GENERAL","Script died: $_ +[0]") and close LOG;}} INIT {$SIG{__WARN__}=sub {LOG_MSG("normal",4,"GENERAL","Script warning +: $_[0]")}} open(LOG,"> SCRIPTLOG_FILE") or die ("Can't open SCRIPTLOG_FILE: $!\n" +); close LOG; print "xx $VERSION"; ### subs sub LOG_MSG { my $par_LEVEL = shift (@_); my $par_SEVERITY = shift (@_); my $par_FUNCTION = shift (@_); my @line = @_; print "> $par_SEVERITY,$par_FUNCTION,@line\n"; print LOG "$par_SEVERITY,$par_FUNCTION,@line\n"; } sub USAGE { my ($message)=<<'MESSAGE'; NAME xxx MESSAGE print "Version:${VERSION}\n$message"; exit; }
Thank you.

Regard DeMichi