in reply to Re: Overriding caller everywhere (BEGIN)
in thread Overriding caller everywhere

Doing the overriding in a BEGIN block is one way to fix that.

And, to be clear for the OP, when you use a module like Sub::Uplevel or Hook::LexWrap (or Contextual::Return), the compilation of those modules happens immediately as a BEGIN block (c.f. docs for use), thus caller is replaced globally before the rest of your code compiles.

use Sub::Uplevel; # *CORE::GLOBAL::caller replaced here print caller(); # calls the replacement

-xdg

Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.