use List::Util qw(min); sub foo {} $x = time(); foreach my $thing ( qw( x foo min time ) ) { printf "$thing is code: %s\n", ( ref *{$main::{$thing}}{CODE} ) ? 'Yes' : 'No'; } __END__ x is code: No foo is code: Yes min is code: Yes time is code: No