CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner: Re: [cluna] Syntax Errors In Program With Hash: Edit Log

Chris Charley

Mar 17, 2013, 7:01 PM

Views: 4415
Re: [cluna] Syntax Errors In Program With Hash

That imports the `sum` function from the List::Util module. (`sum` is used in the formula to find the average of the p-values)

 my $avg = sum( @{ $hash{$region} }) / @{ $hash{$region} };

This takes the sum of the p-values array, @{ $hash{$region} ) and divides the sum by the number of p-values in the array, @{ $hash{$region} }

sum puts it's argument in list context and the division puts the array in scalar context (or the number of p-values).

(This post was edited by Chris Charley on Mar 17, 2013, 7:07 PM)

Edit Log:
Post edited by Chris Charley (User) on Mar 17, 2013, 7:07 PM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives