in reply to why did i die?

Maybe you just want to override 'die()' ?

lanx@nc10-ubuntu:/tmp$ perl -e 'use subs "die"; sub die { print "expec +ted\n" }; eval "4/0"' lanx@nc10-ubuntu:/tmp$ perl -e 'use subs "die"; sub die { print "expec +ted\n" }; eval "die()"' expected

but '&CORE::die' will of course still call the original...

Cheers Rolf

( addicted to the Perl Programming Language)

Replies are listed 'Best First'.
Re^2: why did i die?
by markov (Scribe) on Apr 02, 2014 at 10:40 UTC

    That's not a generic solution. The code I run in the eval can be everything Perl has to offer... for instance runtime requiring any module on CPAN.

      Another option I see¹ is to inspect the source-code.

      Every internal error-msg comes with parsable file and line infos. You could try to match for "die" there.

      Saying this I have to tell you that file and line infos can be manipulated.

      OTOH combining all shown approaches should make it rather difficult to fool your monitoring solution.

      Cheers Rolf

      ( addicted to the Perl Programming Language)

      ¹) beside hacking CORE::die  with XS (which of course can be sabotaged by modules hacking CORE::die  ...)

      So what?

      You have to realize that you won't be able to find a pure Perl solution which can't be sabotaged by evaled pure Perl.

      Cheers Rolf

      ( addicted to the Perl Programming Language)