http://www.perlmonks.org?node_id=586856

xiaoyafeng has asked for the wisdom of the Perl Monks concerning the following question:

hi gurus,

I wonder that's a simple question,but i can't find a better way.I have a log file as below:
timestamp description timestamp description .........
Now, I need to print all description after some timestamp.
below is my code:
..... while (<>) { print if timestamp>threshold; }
my question: I don't wanna compare timestamp every loop,because log file is sorted by timestamp.That is,if one timestamp is greater than threshold, print the rest of all (no comparison). How can do that?


all reply would be appreciated!



UPDATE:
Thanks for your help to let me know my stupidity!In fact,my question is:
how traverse a large sorted(indexed) file faster?
According to your reply,I have three way to do it:
1. flipflop operator
2. binary seek
3. Tie::File (array)
which one is the best? I think nobody but benchmark module could answer it. :-)
Thanks again!