sub there { print "I'm here!"; } my %refs = (there => \&there, not => \¬_there, anon => sub { "I'm here too!" }); foreach (keys %refs) { print "'$_' is ", defined &{$refs{$_}} ? "valid\n" : "invalid\n"; }