in reply to Performing a tail(1) in Perl (reading the last N lines of a file)
_________use Tie::File; my $length = shift @ARGV; my $file = shift @ARGV; tie(my @file, "Tie::File", $file, autochomp => 0) or die("ack - $!"); print @file[$#file - $length + 1 .. $#file];
Update: fixed slice code as it was off by one (as noted by grinder)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Performing a tail(1) in Perl (reading the last N lines of a file)
by Dominus (Parson) on Apr 26, 2002 at 03:37 UTC |