Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: print log file

by johngg (Canon)
on Nov 30, 2006 at 10:56 UTC ( #586908=note: print w/replies, xml ) Need Help??

in reply to print log file

Perhaps you could use Tie::File so that you can access the log file as if it was an array. You could then quickly find the index in the array where the timestamp passes the threshhold by using a binary chop. Look half-way along the array, check the timestamp. If it is less than the threshhold, look again half-way along the upper half, else half-way along the lower half. Repeat, each time chopping the number of elements to be searched in half. Once you have found the element you can print from there to the end of the array.

Just a thought.



Replies are listed 'Best First'.
Re^2: print log file
by MidLifeXis (Monsignor) on Nov 30, 2006 at 18:18 UTC

    Also known as a binary search (term must have changed since I went to college).


      It must have been 25 years ago that I was told about this technique and the name given then was binary chop, I guess because you successively chop the range to be searched in half. Perhaps the name depends on which side of the Atlantic you live. Strangely enough, until today, when I coded one to test if my suggestion worked (it did), I had never had occaision to use one.



Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://586908]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (1)
As of 2021-10-17 03:16 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (71 votes). Check out past polls.