#!/usr/bin/perl -w use strict; sub here { } foreach my $poss ( qw( here not_here ) ) { no strict 'refs'; if (*{$poss}{CODE}) { print "$poss exists.\n"; } else { print "$poss does not.\n"; } } #### #!/usr/bin/perl -w use strict; sub findme { return 0; } sub another {} my $ref; if (rand(1) < 0.5) { $ref = \&findme; } else { $ref = \&another; } foreach (keys %main::) { no strict 'refs'; if (defined *{$_}{CODE}) { if (*{$_}{CODE} eq $ref) { print "\$ref points to $_!\n"; } } }