This also does not work with built-ins:
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
Perhaps you could tell us what problem you're really trying to solve?
If you have some string, and you want to know if it could do something under eval without actually executing it, perhaps you could use 'perl -c' for that. Or, to be really ugly, shell out and see what 'perldoc -f' has to say about it (being very careful about quoting the argument, of course). That would detect built-ins, and you could use one of the other methods listed here for detecting everything else.