while( <> ) { exit 1 if /error.*error/ } open ARGV or die; while( <> ) { ... ## do your stuff }