in reply to How to compute the avg of a column of numbers

Assuming the data is in the array,
my $total=0; map($total+=$_,@values); my $average = @values ? $total / @values : 0;