I think this will work...it did so in my Perl editor. I cleaned up the print command at the end.
Code:
#!/usr/bin/perl
$count=0;
print "Content-type:text/html\n\n";
use CGI ':standard';
#$grade1=param('grade1');
#$grade2=param('grade2');
#$grade3=param('grade3');
#$grade4=param('grade4');
#$grade5=param('grade5');
@array=($grade1,$grade2,$grade3,$grade4,$grade5);
foreach $grade(@array){
print "$grade<br>";
if(($grade !=NULL)||($grade eq 0)){
$count++;
$total=$grade+$total;
}
}
print "<p>";
$average=$total/$count;
print "Number entered: $count<br>Total of Grades Entered: $total<br>Average Grade So Far: $average";