I did something similar on one of my first tries to find out what was going on and to fix this. I looked at the call stack and if there wasn't a ".cgi" file in the list then assumed I was in the "compile" stage and just returned. Not as elegent as using $^S but it worked. If I had to do something like this, I like the $^S way better now that I know about it.

In the end, I'd really like to know why I had to do anything like this. If we have code like:
package X; BEGIN { whatever; } $main::SIG{__DIE__} = \&some_function; # when does this get run? sub new { ... }
In what phase is that SIG handler assigned? I would have thought it was in an implied INIT, but the code acts like it's in an implied BEGIN. I ended up solving the entire issue by putting that line in an explicit INIT block, but why did I have to do that?

In reply to Re^4: SIG, Modules, and Eval by kbrannen
in thread SIG, Modules, and Eval by kbrannen

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.