foreach $file (@files) { if ((!open (FILE, ") #OR if FILE is undefined then { #do something } } }