Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: print log file

by Fengor (Pilgrim)
on Nov 30, 2006 at 07:20 UTC ( #586887=note: print w/ replies, xml ) Need Help??


in reply to Re: print log file
in thread print log file

Since there is always more than one way to do it. Here would be my guess to traverse the file faster:

my $jmp_distance = 100; my $treshhold = $FOO my $line = <FILE>; (my $tstamp, my $rest) = split(/\s+/,$line,2); #skipping through file by jumping over $jmp_distance lines do { $. += $jmp_distance; $line = <FILE>; ($tstamp, $rest) = split(/\s+/,$line,2); } while ($tstamp<=$treshhold) #since we overshot with the last jump $. -= $jmp_distance; while (<FILE>) { ($tstamp, $rest) = split(/\s+/,$_,2); print if $tstamp > $treshhold; }
Of course you can modify this further. For example putting the whole do whileloop in a sub and recursively call it with shorter jmp_distances. that way you could start with a distance of 10000 and then go to shorter distances like 1000, 100, 10 and 1 (1 = condition to break the recursion) if you call the sub with jmp_distance/10.

--
"WHAT CAN THE HARVEST HOPE FOR IF NOT THE CARE OF THE REAPER MAN"
-- Terry Pratchett, "Reaper Man"


Comment on Re^2: print log file
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (12)
As of 2014-11-24 20:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (147 votes), past polls