in reply to How to de-reference a coderef?
Returns something like pkgname::__ANON__ for anonymous subs, or undef if something goes wrong (like being passed an array ref instead of a code ref).use B; sub coderef2name { eval { my $obj = B::svref_2object( shift() ); $obj->GV->STASH->NAME . "::" . $obj->GV->NAME; } || undef; }
Updated to use GV->STASH->NAME, not STASH->NAME. Thanks, betterworld
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: How to de-reference a coderef? (B tricks)
by Anonymous Monk on Aug 24, 2011 at 01:14 UTC | |
by ikegami (Pope) on Aug 25, 2011 at 04:29 UTC | |
by Anonymous Monk on Aug 25, 2011 at 01:14 UTC |