Junaid Najamuddin wrote at Fri, 09 Aug 2002 23:22:45 +0200:

> I am trying to read the last 10 lines of a log file. 

There are also some other ways to read the last 10 lines
without you'll have to implement the logic for yourself:

tie my @line, 'Tie::File', 'log.dat' or die "...";
my @last_ten = @line[-10 .. -1];


or perhaps

tie *FILE, 'File::ReadBackwards', 'log.dat' or die " ... ";
my @last_ten = ();
push @last_ten, scalar <FILE> for (1 .. 10);

what could be perhaps a little bit more efficient,
I didn't tried it.


On the other hand,
there's also a module
File::Tail that helps observing the changes of log files.


Best Wishes,
Janek


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to