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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Find the name of a CODEref
by imp (Priest) on Aug 25, 2006 at 12:06 UTC | |
|
Re: Find the name of a CODEref
by GrandFather (Saint) on Aug 25, 2006 at 04:01 UTC | |
by jdporter (Paladin) on Aug 25, 2006 at 12:58 UTC | |
|
Re: Find the name of a CODEref
by ysth (Canon) on Aug 25, 2006 at 16:26 UTC | |
|
Re: Find the name of a CODEref
by diotalevi (Canon) on Aug 28, 2006 at 14:23 UTC |