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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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



Chris Charley
User

Mar 17, 2013, 7:01 PM


Views: 1239
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)

Code
 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