while ($line2=) { chomp $line2 ; if (substr($line2, 0 , 3) eq "---") { break ; } ; .... } ;