in reply to Finding the name of the target of a coderef
This will match `bob' and nothing else.sub bob { print 'bob'; } my $match = \&bob; my $nomatch = sub { print 'nob'; }; *alias = \&bob; for my $key (keys %main::) { if ($match == \&{$key}) { print "matched to $key\n"; } if ($nomatch == \&{$key}) { print "matched to $key\n"; } }
This will only find subroutines in the main package.
Update: Added Alias for completness.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Finding the name of the target of a coderef
by adamk (Chaplain) on Apr 15, 2005 at 02:32 UTC |