in reply to passing the reference of hash values array

Try this:

my $mean_of_arr = &average(values %arr);

...roboticus