eclark has asked for the wisdom of the Perl Monks concerning the following question:
According to perlvar, $^S has three states: true, false or undefined. True inside eval, false elsewhere, or undefined if parsing is not finished. This has the effect of $^S always being undef when die occurs in a BEGIN block (or use.) I'm stuck at this point, so I need to find a way around it.
How do I know if my DIE handler is being called within an eval when parsing is not yet complete?
example:BEGIN { $SIG{__DIE__} = sub { die @_ if $^S; # dont mess with eval. # ...my custom handler code... exit(0); } eval { die 'another day'; }; if ($@) { # execution never happens }; } eval { die 'to day good'; }; if ($@) { # this works };
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: BEGIN, eval {} and $^S
by diotalevi (Canon) on Dec 17, 2003 at 00:39 UTC | |
by eclark (Scribe) on Dec 17, 2003 at 02:57 UTC | |
by diotalevi (Canon) on Dec 17, 2003 at 03:36 UTC | |
Re: BEGIN, eval {} and $^S
by ysth (Canon) on Dec 17, 2003 at 08:02 UTC |
Back to
Seekers of Perl Wisdom