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

Yes - a small queue would do this. Since you're so new, you'll do yourself a world of good by picking up a copy of the inexpensive book Learning Perl (also known as the Llama book) from O'Reilly.

while (<>) { push @queue, $_; print shift @queue if @queue > 2; }