#!/usr/bin/perl use warnings; sub foo { my $name = shift; if(my $ref = *{$name}{CODE}) { print "ref = $ref\n"; } } BEGIN { foo('bar'); foo('baz'); }