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

Re: Selecting a particular record from groups of records

by pvaldes (Chaplain)
on Sep 21, 2012 at 16:57 UTC ( #994947=note: print w/ replies, xml ) Need Help??


in reply to Selecting a particular record from groups of records

use strict; use warnings; use List::Util qw(min); my %seahash; my $date; my $time; my $coolflag; while(<DATA>){ next if /^date\/time/; chomp; my ($date, $time, $lat, $lon, $depth, $flag, $coolflag, $otherflag) = + split; # you could need the other variables later, so I save it # print $date, " ",$time, " ", $coolflag,"\n"; # checkpoint push @{$seahash{$date . " " . $time}}, $coolflag; } while (my ($timestamp, $flags) = each (%seahash)) { print $timestamp, " ", min(@{$flags}),"\n"} __DATA__ date/time lat, lon, depth, flag, flag, flag 21-sep-2012 01:00:00 0 0 -200 a 1 c 21-sep-2012 01:00:00 0 0 -100 a 9 c 20-sep-2012 02:20:00 0 0 -1500 a 2 c 20-sep-2012 02:20:00 0 0 -500 a 4 c 20-sep-2012 02:20:00 0 0 -400 a 3 c 20-sep-2012 02:20:00 0 0 -300 a 3 c 10-Aug-2012 02:20:00 0 0 -200 a 3 c 10-Aug-2012 02:20:00 0 0 -200 a 1 c 10-Aug-2012 02:20:00 0 0 -200 a 7 c


Comment on Re: Selecting a particular record from groups of records
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2014-12-25 23:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (163 votes), past polls