in reply to Re^2: Matching on a specific line of text
in thread Matching on a specific line of text

add a else{ last } to the if statement so it doesn't bother reading the rest of the file.
Careful if there are holes in your test range... you might jump out of the loop too early. In that case, it's best to do an explicit compare against the maximum line number you're interested in.
elsif($. > $lastline) { last; }