in reply to Finding the name of the target of a coderef

How about:
#!/usr/bin/perl sub foo { print "In foo\n"; } sub findit { my $ref = shift; local(*alias); *stash = *{"main::"}; while ((my $varname, my $globvalue) = each %stash){ next if $varname eq "alias"; *alias = $globvalue; if (defined(&alias)){ if ($ref eq \&alias){ return $varname; } } } } my $fref = \&foo; my $fname = findit($fref); print "ref points to $fname\n";
bryan@web ~$ ./ns
ref points to foo
bryan@web ~$