use strict; use warnings; my $func = \&main::non_defined_code; if( function_exists( $func )) { print 'YES'; } else { print 'NO'; } print "\n";