in reply to Catching DIE no matter what

Unfortunately you can't prevent the program terminating like this - as described in perlvar:

The routine indicated by $SIG{__DIE__} is called when a fatal exception is about to be thrown. The error message is passed as the first argument. When a __DIE__ hook routine returns, the exception processing continues as it would have in the absence of the hook, unless the hook routine itself exits via a "goto", a loop exit, or a die(). The "__DIE__" handler is explicitly disabled during the call, so that you can die from a "__DIE__" handler. Similarly for "__WARN__".
If you want to catch this *and* not actually die then you need to use eval as well:
local $SIG{__DIE__} = \&foo; + + eval { die "Aiieeee!"; }; + sub foo { print "COpped die"; }

/J\

Replies are listed 'Best First'.
Re^2: Catching DIE no matter what
by jdhedden (Deacon) on Aug 05, 2005 at 16:27 UTC
    kosun, as gellyfish's quote from perlvar says, you might be able to control things with a 'goto':
    $SIG{'__DIE__'} = sub { if ($_[0] =~ /matched error text/) { print('Warning - continuing after error: ', $_[0]); goto &foo; } else { print($_[0]); } }; sub foo { print("Continuing in 'foo'...\n"); # Do more work... }
    Your app will then exit when 'foo' returns.

    Remember: There's always one more bug.