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