in reply to Re: Print all lines in a file except the last two
in thread Print all lines in a file except the last two

There is a magic variable that keeps track of the current line number from the last-read filehandle. This would make your while loop a bit simpler:

$. < $lines - 2 and print while <F>