in reply to Re^2: die not exiting Application
in thread die not exiting Application
In case die is overridden, you can call CORE::die instead.
Update: maybe I should mention that this wouldn't help much, though, if the die should somehow happen to be trapped by an eval { ... } block (which I don't know)... In this case, you could try something along the lines of
open my $fh, "<", $file or warn "Couldn't open '$file': $!" and ex +it;
to force the program to terminate.
Consider this
my $file = "does-not-exist"; while (<STDIN>) { eval { open my $fh, "<", $file or warn "Couldn't open '$file': $!" and exit; }; print STDERR "ERROR: $@" if $@; }
(which would actually terminate the program) vs.
while (<STDIN>) { eval { open my $fh, "<", $file or CORE::die "Couldn't open '$file': $!"; }; print STDERR "ERROR: $@" if $@; }
which would continue printing (despite the CORE::die)
ERROR: Couldn't open 'does-not-exist': No such file or directory at ./ +680735.pl line 10, <STDIN> line 1. ERROR: Couldn't open 'does-not-exist': No such file or directory at ./ +680735.pl line 10, <STDIN> line 2. ...
...if you keep hitting the ENTER key.
(If necessary, you could of course also use CORE::warn or CORE::exit in combination with the above...)
|
|---|