Help for this page
my $MAXLINES=20; # not including header open my $fh, '+<', 'foo.txt' or die $!; ... seek $fh, 0, 0 or die "seek failed"; print $fh @lines; close $fh;
use Tie::File; my $MAXLINES=20; # not including header ... splice @lines, 1, @lines-$MAXLINES if @lines>$MAXLINES; push @lines, "newline\n"; untie @lines;