You May use the 'List::Util' module for this task.
use strict; use warnings; use List::Util('sum'); ## Store the hash value my %hash = ( 'A' => 46, 'D' => 18, 'C' => 17, 'B' => 31 ); ## values %hash -> gives the values of the hash ## keys %hash -> get number of element in this hash my $sum = sum (values %hash)/keys %hash; print $sum;
In reply to Re^2: get the average of hash values?
by k_manimuthu
in thread get the average of hash values?
by luckysing
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |