OlegG has asked for the wisdom of the Perl Monks concerning the following question:

I want something strange.
Here is my attempt
package Xxx; sub xxx { my $xxx = eval { die 'xxx' }; } package main; *Xxx::eval = sub(&) { warn "You should die"; $_[0]->(); }; Xxx::xxx();
But this doesn't work.
Or may be you can tell me how to prevent exceptions catching in some package without source code modification of this package?

Replies are listed 'Best First'.
Re: Any chance to redefine "eval BLOCK" in the package?
by chromatic (Archbishop) on Sep 14, 2011 at 19:56 UTC
    Or may be you can tell me how to prevent exceptions catching in some package without source code modification of this package?

    Replace the eval opcode with one which does nothing while the current package is your target package. You'll have to write XS for this to work.

    From the world of pure Perl, you're unlikely to get this to work.


    Improve your skills with Modern Perl: the free book.

      Ok, that sounds good. I'll try.
      Found some example of opcode patching in the Coro::Select module. If you know other places where I can read about that, please let me know.
Re: Any chance to redefine "eval BLOCK" in the package?
by ikegami (Patriarch) on Sep 14, 2011 at 18:43 UTC
    Replace xxx instead of eval?