Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://994947]
help
Chatterbox?
[Lady_Aleena]: Having to rewrite some parts of my site for mobile devices is such a pain in the butt.
[shmem]: Lady_Aleena: what editor are you using, on what platform?
[Lady_Aleena]: shmem, geany on Debian jessie.
[shmem]: some experience with vim?
[Lady_Aleena]: None
[shmem]: I don't know geany, and don't know whether it has support for ctags.
[Lady_Aleena]: ctags?
[shmem]: ctags is a program which (recursively) extracts the symbols from source and stores them in a one-file database. This allows you to query the locations where these symbols (e.g. a subroutine name) are used anywhere in the source code tree...
[shmem]: ...from inside the editor.

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (7)
As of 2017-04-27 12:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (505 votes). Check out past polls.