$foo="nosuchmodule"; sub has {print "ok\n"} sub hasnt {print "no dice\n"} eval "require $foo" ? has : hasnt