in reply to Programming Perl 3rd ed. Chapter 1

$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.