in reply to seeking advise on average value problem
Something like this would load that sort of hash, and then print summary values for each primary hash key:
my %stats; while (<>) { next unless ( /^(\w+):\s+([\d.]+)/ ); $stats{$1}{count}++; $stats{$1}{sum} += $2; } printf( "%20s %5s %8s\n", "Name", "Count", "Average" ); for ( sort keys %stats ) { printf( "%19s: %5d %8.2f\n", $_, $stats{$_}{count}, $stats{$_}{sum} / $stats{$_}{count} ); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: seeking advise on average value problem
by rangersfan (Novice) on Mar 26, 2006 at 00:21 UTC | |
by rangersfan (Novice) on Mar 26, 2006 at 00:52 UTC | |
by rangersfan (Novice) on Mar 26, 2006 at 01:18 UTC | |
by graff (Chancellor) on Mar 26, 2006 at 01:47 UTC | |
by rangersfan (Novice) on Mar 27, 2006 at 01:08 UTC |