Just put your data into a hash of arrays, and then loop on the compiled data using List::Util->max to determine the max value in each array.
The below snippet demonstrates what I'm talking about with the fake data you listed:
use List::Util qw(max); use strict; use warnings; my %vals; # Put Data into a Hash of Arrays while (<DATA>) { chomp; my ($key, $val) = split; push @{$vals{$key}}, $val; } for my $key (sort {$a <=> $b} keys %vals) { my $max = max @{$vals{$key}}; print "$key $max\n"; } =prints 1 4 2 7 3 10 =cut __DATA__ 1 3 1 2 1 4 2 5 2 7 3 10 3 0
In reply to Re^3: Excel and Perl
by wind
in thread Excel and Perl
by kb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |