I can't believe I just beat John in perl golf, by 14 strokes!
(Anyone who knows me knows I just got lucky on that hole...) - B > chen li wrote: >> Dear all, > > Hello, > >> 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. >> >> my @data=(1,1,1); >> >> mean=(1+1+1)/3=1;(Any perl built-in function for >> this?) > > my $mean = do { my $s; $s += $_ for @data; $s / @data }; > > > John -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>