in reply to Programming Perl 3rd ed. Chapter 1

The only way you are going to have a division by zero error is if there are no elements in @grades for a given $student. Simple way to debug is to add a print after @grades = split... that goes something like
print "student: $student :: grades: " . $grades{$student} . "\n"; or print "student: $student :: grades: " . join( ' ', @grades ) . "\n";

and see if any of the data looks inappropriate.

Replies are listed 'Best First'.
Re: Re: Programming Perl 3rd ed. Chapter 1
by blacksmith (Hermit) on Jun 23, 2001 at 02:03 UTC
    Thanks guys. I think I found out what happened. The code had a space between the quotes in the 12th line. I took that space out and the program ran without an error message. The students got some really poor scores. HAHAHA. Thanks for the input. I think that got it.
    Blacksmith.