Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Getting code-ref of anonymous callerby LanX (Saint) |
on Jul 31, 2020 at 15:13 UTC ( [id://11120151]=perlquestion: print w/replies, xml ) | 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:
Cheers Rolf
Back to
Seekers of Perl Wisdom
|
|