#!/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"; } } }