#! perl use strict; use warnings; my $header_lines = $ARGV[0] // 0; my $footer_lines = $ARGV[1] // 0; for 1 .. $header_lines; # Throw away the header my @lines; while () { push @lines, parse_line($_); print shift @lines if @lines > $footer_lines; } sub parse_line { my ($line) = @_; # ...Parse $line... return $line; } __DATA__ Header 1 Header 2 Text 1 Text 2 Text 3 Text 4 Text 5 Footer 1 Footer 2 Footer 3 #### 0:50 >perl 1348_SoPW.pl 2 3 Text 1 Text 2 Text 3 Text 4 Text 5 0:55 >