In this quiz, you'll be writing a Perl program to process a file of bowling scores in the following format:
Dean 150 John 200 Dean 100 Mary 50 Janice 300 Janice 100
We'll start by giving you a program that computes the number of times each person has bowled a game. The program is:
#! /usr/local/bin/perl while ($line=<>) { chop($line) ; @words=split(/\s+/, $line) ; ++$numgames{$words[0]} ; } foreach $name (sort(keys(%numgames))) { printf ("%-8s bowled %2d games\n", $name, $numgames{$name}) ; }
The output of the program, when run using the bowling score input file, is:
Dean bowled 2 games Janice bowled 2 games John bowled 1 games Mary bowled 1 games
Now, Make a simple modification of th program: Make the program print out the average score. Your output should look something like:
Dean averages 125 points Janice averages 200 points John averages 200 points Mary averages 50 points
By the way, you really don't have to change much.