in reply to Getting name of sub from a hash-based dispatch table?
Returns false if something goes wrong (like not getting a coderef). Name will be pkg::__ANON__ for anonymous subs. And if the coderef is to an exported sub, the original name and package will be given.sub getsubname { use B 'svref_2object'; my $coderef = shift; join '::', eval { svref_2object($coderef)->GV->STASH->NAME }, eval { svref_2object($coderef)->GV->NAME } }
|
|---|