if(defined &main::foo){ foo(); } else{ print "Funktion nicht vorhanden\n"}