You May use the 'List::Util' module for this task.
## 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;
I don't understand. The OP wants an average for each of 'A', 'B', 'C', 'D' (four numbers). Your input (%hash) doesn't have the information to do that, and your output (a ratio, called '$sum') is a single number.