in reply to Average calculation
"I'm using hash" is not illustrative enough of the code you've tried so far. Is this your homework? Do you want us to do it for you?
Hints: first, learn about split. Then, suppose you somehow you've managed to obtain a %temp hash, which happens to be a "HoA"; you probably will do something like:
for (keys %temp) { my $tot; $tot += $_ for @{ $temp{$_} }; print "Average for state '$_': ", $tot/@{ $temp{$_} }, "\n"; }
but possibly with additional checks and taylored to your needs. Suggested readings: perlref and the other docs mentioned there under the heading "SEE ALSO".
|
|---|