my $linesToSkip = 2; my $discard = for 1 .. $linesToSkip; while ( ) { # Do something here with the lines of interest. ... }