use B; sub findit { my $ref = shift; die "I only work for CODErefs!" unless ref $ref eq 'CODE'; my $package = B::svref_2object($ref)->START->stashpv; local(*alias, *stash); *stash = *{"${package}::"}; while ((my $varname, my $globvalue) = each %stash){ next if $varname eq "alias"; *alias = $globvalue; if (defined(&alias)){ if ($ref == \&alias){ return $varname; } } } return undef; }
In reply to Find the name of a CODEref by Dylan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |