I'm trying to do the right thing by testing $^S in my SIG{__DIE__} handler. Thing is, I wasn't able to test for the case $^S==0 aka "neither compiling nor eval'ing".
It turns out I was hitting a bug in perl "v5.6.1 built for sun4-solaris-64int", which is installed on my work's server. I'm posting the results here, because I didn't see the answer elsewhere on perlmonks.
Here's test code:
$SIG{__DIE__} = sub { if (!defined($^S)) {warn "Compiling death\n"} elsif ($^S) {warn "Eval death\n"} else {warn "Other 'die':",@_,"\n"}; }; print 'Enter "e" to cause an eval death, "n" to skip runtime: '; $_=<STDIN>; eval 'die "^^This is an eval die\n";' if /e/; print "Eval tried to die with this err: $@\n" if $@; die "^^ Compiling or run-time death?" unless /n/;
On perl v5.6.1 built for sun4-solaris-64int, $^S is never defined and equal to 0. In fact, the final "die" does not alter the value of $^S at all! If you enter "e" and cause an eval death, both calls to die warn "Eval death". If you don't enter "e" the handler warns "Compiling death".
perl 5.10.1 on windows does the right thing, it warns "Other" on the last "die".
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |