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 };
In reply to BEGIN, eval {} and $^S by eclark
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |