Home: Perl Programming Help: Beginner:
Need a logic for this program.


Oct 1, 2012, 10:14 PM

Views: 1950
Need a logic for this program.


I am beginner in perl, I am looking for logic for program for solving in perl language .
"I have 10GB log file, Which append the data to the end of the file every five minutes. I need to reverse the file like the latest input to first line of first page and the oldest data to last line of the last page of the log file. I can use only 1 GB of ram memory."

using 1 GB ram memory so we cant use the inbuild functions like reverse and other options.What would be the efficient way. Any algorithm or pseudo code would help me a lot thanks.

Veteran / Moderator

Oct 2, 2012, 12:43 AM

Views: 1948
Re: [maneshmotts] Need a logic for this program.


the best is probably to use the File::ReadBackwards module.

From the documentation of this module:

This module reads a file backwards line by line. It is simple to use, memory efficient and fast. It supports both an object and a tied handle interface.

It is intended for processing log and other similar text files which typically have their newest entries appended to them. By default files are assumed to be plain text and have a line ending appropriate to the OS. But you can set the input record separator string on a per file basis.