Re: Best method for seeking to n lines before end of file [ implementation of tail ]



xhoster@xxxxxxxxx wrote:

graemenewlands@xxxxxxxxx wrote:
Hello,

Perhaps someone can help me with a problem I have at the moment and is
causing some debate with my colleagues:

What is the best technique

best according to what criteria?

to seek to the end of a file and load in
say, the last 10 lines like the tail command does.

I like:

open my $fh, "-|", "tail", "-10", $file or die $!;
my @foo = <$fh>;

Perhaps not best in terms of portability, though.

if you have to install Perl, installing a tail port shouldn't be a big
issue :-)

--
John Bokma Freelance software developer
&
Experienced Perl programmer: http://castleamber.com/
.