#!/usr/bin/env perl
use strict;
use warnings;
use autodie;
my $file = 'pm_1139175_skip_head_and_foot.txt';
my ($headers, $footers) = (2, 3);
open my $fh, '<', $file;
<$fh> for 1 .. $headers;
my $last_head_pos = tell $fh;
1 while <$fh>;
my $last_data_line = $. - $footers;
seek $fh, $last_head_pos, 0;
$. = $headers;
while (<$fh>) {
last if $. > $last_data_line;
print;
}
close $fh;
####
$ cat pm_1139175_skip_head_and_foot.txt
head1
head2
data1
data2
data3
data4
foot1
foot2
foot3
####
$ pm_1139175_skip_head_and_foot.pl
data1
data2
data3
data4