Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

And yet more $SIG{__DIE__} fun...

by Adam (Vicar)
on Nov 01, 2000 at 02:38 UTC ( #39345=perlquestion: print w/ replies, xml ) Need Help??
Adam has asked for the wisdom of the Perl Monks concerning the following question:

So I was working with $SIG{__DIE__} trying to do some fancy stuff and I discovered that $SIG{__DIE__} gets called from within an eval block! This was really not cool since I wanted to use the eval block to capture the die. Sigh. Any ideas?
#!perl -w use strict; $SIG{__DIE__} = sub { print "SIG DIE called!\n", caller, $/ }; eval qq{die 'inside eval!'}; print uc($@); __END__ The above code, when run, outputs: SIG DIE called! main(eval 1)1 INSIDE EVAL! AT (EVAL 1) LINE 1.

Comment on And yet more $SIG{__DIE__} fun...
Download Code
Replies are listed 'Best First'.
Re: And yet more $SIG{__DIE__} fun...
by Fastolfe (Vicar) on Nov 01, 2000 at 02:42 UTC
    This is adequately documented in perlvar (%SIG) and the documentation for die (at the bottom). A workaround is to put this as the first line in your signal handler for __DIE__:
    die @_ if $^S;
      Ooooh. I've never used $^S before. Thanks!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://39345]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2016-06-01 08:03 GMT
Find Nodes?
    Voting Booth?

    No recent polls found