Hi,

This example should be good for your memory:

---------------

#!/usr/bin/perl -w

open(FILE, "< yourbigfile.txt") or die $!;

my @last5;

while (<FILE>) {

push @last5, $_; 

shift @last5 if @last5 > 5; 

}

print @last5;

----------------

Inspired by "Beginning Perl - Wrox".

Regards,

Jostein


On Monday 28 October 2002 19:54, Nikola Janceski wrote:
> without using 'tail' how can I get the trailing 5 lines of a large file
> quickly, without loading it all to memory?
>
> is there anyway without pop and shifting through an array foreach line? (<=
> this is the only way I could think of doing it)
>
> Distribution Homepage <http://www/groups/product/Software_Distribution>
>
> Nikola Janceski
> Summit Systems, Inc.
> 212-896-3400
>
> Clever talk and a pretentious manner are seldom found in the Good.
> -- Confucius
>
>
> ---------------------------------------------------------------------------
>- --------------------
> The views and opinions expressed in this email message are the sender's
> own, and do not necessarily represent the views and opinions of Summit
> Systems Inc.


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

Reply via email to