$scores begins with a value of zero, and is incremented in the foreach loop, which iterates over the @grades array. Chances are, your split() statement is returning an empty list leaving @grades empty and nothing for the foreach loop to do, so the value of $scores remains at zero and causes the error in $average = $total / $scores.
In reply to Re: Programming Perl 3rd ed. Chapter 1
by converter
in thread Programming Perl 3rd ed. Chapter 1
by blacksmith
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |