Put this print statement in the second for loop:
print "Evens = $Evens, Odds = $Odds\n";
and you’ll see that on the sixth iteration, $Evens is 10 and $Odds is 11 — both referring to uninitialised elements of array @list. So the division becomes 0 / 0, which gives the error.
hdb has shown how to fix this.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re: phi div by 0 error
by Athanasius
in thread phi div by 0 error
by perlaintdead
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |