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".


In reply to defined $^S && $^S == 0 in $SIG{__DIE__} - answered my own question by Yary

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.