Read everything before doing anything!
Your program will read data from a file that describes the competitors for the Central Coast Section High School Wrestling Tournament (yes, this is a real data file). Here is its format:
The Central Coast Section is divided into eight leagues, each covering a particular geographical area. For example, BVAL is the Blossom Valley Athletic League, which covers most of the schools in East San Jose.
Each league has its own tournament to find out who qualifies for the section tournament. Some of the smaller leagues can send only two qualifying athletes to the tournament; some larger leagues can send as many as seven from each of fourteen weight classes.
All this information is in the file
ccs_all.txt
, which you should
download and save. Do not retype the information! The
ccs_all.txt
file is
is formatted like this:
BYE
(all uppercase) and
the school name will be ---
(three hyphens).
Your program will take this data and build the following data structures:
A hash of arrays. The key to the hash is a school name, and the value is an array consisting of all the competitor names and weights from that school. Alternates (marked with an asterisk) and BYEs do not appear in the output file!
A hash of hashes. The key of the primary hash is the league name; the value is another hash whose key is the school name and whose value is the number of people from that school, excluding alternates (marked with an asterisk) and BYEs.
Your program will then produce the following output:
all_teams.txt
. It will have this
format:
Each roster starts with the team name on a single line by itself, followed by competitor weights and names (one line each).
Weights and names are separated by whitespace, and may have leading whitespace. Example:
Peoria High School 105 Joe Schemegeggie 114 John Doe 121 Juan Fulano
league_list.txt
.Here is what the resulting team file should look like, and this is a sample of what the league file should look like (you may choose a different format for this file if you wish.)
Your program must use the “pointer notation” at least once. Your output must be properly labelled. Your program must have comments at the beginning which describe the type of input, processing, and output that the program will perform. These comments must be detailed. See an example of a different program with appropriate comments, or see the complete solution to this different program. Note that its input file is in exactly the same format as the first output file that you have created.
You must use strict;
in your program.
If the input file doesn’t exist, or if an error occurs when you
open an output file, you must print an error message
and exit. You may use the die( )
function for this.
The input file contains information that you do not need in your output file, so you don’t need to process it.
The file is “clean.” There are no leading blanks on
any lines. No legitimate competitor name begins with the word
BYE
. There are no extraneous blank lines (except at the end
of the file).
Do not try to debug this program with the entire source file. Instead, make a shorter version of the file with only two leagues and four schools so that you can see that the results are correct.
Please name your file in the form lastname_firstname_ref.pl
and
email it to the instructor when you finish.