On Sep 9, 2006, at 9:48 PM, Randal L. Schwartz wrote:

"Xavier" == Xavier Noria <[EMAIL PROTECTED]> writes:

Xavier> On Sep 9, 2006, at 9:00 PM, chen li wrote:
I want to calculate the mean of an array. I know how
to let the job done by using a loop. But I just wonder
if Perl has the short-cut/built-in function for this.

Xavier> There are modules, but nothing builtin.

List::Util is "built-in" as of 5.8, and back compatible to 5.5 I think.

use List::Util qw(sum);

my $average = sum(@input) / @input;

I know, but that's not a builtin mean().



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to