Try this:
open SCORES, "a:/scores.txt" or die "Error: $! while opening scores fi +le\n"; my $students = 0; my $totalscore = 0; while (<SCORES>) { chomp; my @line = split /:/; while (@line) { my $student = shift @line; my $score = shift @line; print "$student\n$score\n"; $students++; $totalscore += $score; } } print "average: ", $totalscore/$students, "\n" if $students;
Update: fixed embarrassing typos and minor errors
In reply to Re: not loading all test data
by xmath
in thread not loading all test data
by zonmoy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |