open SCORES, "a:/scores.txt" or die "no scores!"; while() { chomp; # turn the data into a hash, with names as keys # and scores as values my %scores = split(':',$input); # add up all the values my $total = 0; map { $total += $_; } values %scores; # divide the total by the number of names in the hash # to get the average. my $average = $total / (keys %scores); print "the average of the scores is $average\n"; } close(SCORES);