Chris Charley
User
Mar 17, 2013, 7:01 PM
Views: 1369

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 pvalues) my $avg = sum( @{ $hash{$region} }) / @{ $hash{$region} }; This takes the sum of the pvalues array, @{ $hash{$region} ) and divides the sum by the number of pvalues 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 pvalues).
(This post was edited by Chris Charley on Mar 17, 2013, 7:07 PM)
