use strict; $tmp="some file"; open (FILE,"$tmp"); while() { if (/file error/i) {print "error in file";} else {print"@_ no error";} }