if ($image and -e $file) { # printed even if $image is '' or undef print "Yes image exists\n"; } else { print "No image doesn't exist\n"; }