arrow has asked for the wisdom of the Perl Monks concerning the following question:
for (my $num = $members) { foreach $month2 (@calendar) { foreach $name2 (@members) { if ($hoursWorked{$name2}{$month2} == 0) { $num--; #this is to protect against false averages, because $members w +ill usually have a value of 13, but I don't want to count the zero va +lues because is would result in an incorrect average, (i.e. 24/6 inst +ead of 24/13 because only 6 people worked)
$avg{$month2} += $hoursWorked{$name2}{$month2}; } } if ($num == 0) { $avg{$month2} = 0; } else { $avg{$month2} = $avg{$month2}/$num; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Mathematical averages
by dpuu (Chaplain) on Nov 22, 2002 at 22:41 UTC | |
|
Re: Mathematical averages
by dws (Chancellor) on Nov 23, 2002 at 01:00 UTC | |
|
Re: Mathematical averages
by arrow (Friar) on Nov 23, 2002 at 04:00 UTC |