my $line_id = 0; LINE: while (my $line = <$IN>) { $line_id++; next LINE if $line_id < $n; # now parse the interesting part of the file ... }