tail can efficiently be done using File::ReadBackwards.
# Displays the last $n lines of $file_name, # earliest first. my $file_name = 'file.log'; my $n = 5; my $fh = File::ReadBackwards->new($file_name) or die("Can't read input file: $!\n"); my @lines; for (1..$n) { my $line = $fh->readline(); last if not defined $line; unshift(@lines, $line); } print foreach @lines;
Update: marto's suggestion seems to be more appropriate.
In reply to Re: Perl Tail ?
by ikegami
in thread Perl Tail ?
by perlAffen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |