Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As explained in <a href="http://perldoc.perl.org/perlvar.html#%25SIG" rel="noreferrer">perlvar</a>, due to an implementation glitch <code>$SIG{__DIE__}</code> hooks get called even when code <a href="http://perldoc.perl.org/functions/die.html" rel="noreferrer">die</a>s inside an <a href="http://perldoc.perl.org/functions/eval.html" rel="noreferrer">eval</a>. When <a href="http://search.cpan.org/perldoc?File::stat" rel="noreferrer">File::stat</a> is loaded, it checks to see what constants <a href="http://search.cpan.org/perldoc?Fcntl" rel="noreferrer">Fcntl</a> supports on your platform. It catches the errors caused by unsupported constants, but not before your hook sees them.</p> <p>You can tell if you're in an <code>eval</code> by checking the value of <a href="http://perldoc.perl.org/perlvar.html#$EXCEPTIONS_BEING_CAUGHT" rel="noreferrer"><code>$^S</code></a>. If it's not 0, then you're in an eval.</p> <pre><code>$SIG{__DIE__} = sub { return unless defined $^S and $^S == 0; # Ignore errors in eval my ($error) = @_; chomp $error; print "die: $error\n"; }; </code></pre> <p>You don't see the errors when you <code>use</code> instead of <code>require</code> because <code>use</code> is a compile-time operation and <code>require</code> is a run-time operation (as is setting <code>%SIG</code>). When you <code>use mod</code> and it <code>use</code>s File::stat, that all happens <em>before</em> you set up your hook. When you <code>require mod</code>, that doesn't happen until <em>after</em> you've installed your hook.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload