in reply to Let a module call a sub of the caller

B::Hooks::EndOfScope or perhaps Hook::AfterRuntime (or even a combination of the two) ought to do the trick.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
  • Comment on Re: Let a module call a sub of the caller