open SCORES, "a:/scores.txt" or die "Error: $! while opening scores file\n"; my $students = 0; my $totalscore = 0; while () { 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;