Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Time Intervals

by johngg (Abbot)
on Jun 27, 2012 at 22:13 UTC ( #978781=note: print w/replies, xml ) Need Help??


in reply to Time Intervals

Construct a hash of arrays keyed by value in the file, containing arrays of lines for each value in case there is more than one time period with the same value. Use List::Util->max to find the largest key in the hash and print the line(s) associated with it.

knoppix@Microknoppix:~$ perl -Mstrict -Mwarnings -MList::Util=max -E ' > open my $fh, q{<}, \ <<EOD or die $!; > 10:38:34 759 > 10:43:34 735 > 10:48:34 817 > 10:53:34 648 > 10:58:34 817 > 11:03.34 774 > EOD > > my %byValue; > while ( <$fh> ) > { > my $value = ( split )[ 1 ]; > push @{ $byValue{ $value } }, $_; > } > > print for @{ $byValue{ max keys %byValue } };' 10:48:34 817 10:58:34 817 knoppix@Microknoppix:~$

I hope this is helpful.

Cheers,

JohnGG

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://978781]
help
Chatterbox?
[Corion]: I guess I have to dump the JSON commands I send and file a bug report with the Chromium devs

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2017-10-17 12:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (230 votes). Check out past polls.

    Notices?