use List::Util qw(sum); sub mean { return sum(@_)/@_; }
sum returns the summation of all the elements in the array. Dividing by @_ (which in scalar context gives the number of elements) returns the average.
In reply to Re: Get average value of array of numbers
by bruno
in thread Get average value of array of numbers
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |