|Pathologically Eclectic Rubbish Lister|
Getting code-ref of anonymous callerby LanX (Cardinal)
|on Jul 31, 2020 at 11:13 UTC||Need Help??|
LanX has asked for the wisdom of the Perl Monks concerning the following question:
As the following demo shows is caller(1) reporting the name of the calling sub + package.
In the case of a named subroutine one is able to get the code-ref of the caller by inspecting the STASH.
But this doesn't work with anonymous subs.
Caller claims they are part of the stash (here main::__ANON__ ) but accessing the associated code-ref fails. It most likely a newly autovivificated code-ref.
Any better way to get the callers code-ref?
First the output
Here the demo: