use warnings; use strict; my %r; while (<DATA>) { chomp; my ($k, $s) = split; $r{$k}{count}++; $r{$k}{sum} += $s; } for my $key (sort keys %r) { print "$key\t$r{$key}{count}\t", ($r{$key}{sum}/$r{$key}{count}), +"\n"; } __DATA__ 1 196 1 190 1 200 2 20 3 25 3 19 3 39 4 40 4 41
In reply to Re: Data munging
by toolic
in thread Data munging
by umasuresh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |