CIT 042 Index > Program: References

Programming Assignment
Using References and Files

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:

  1. Each league starts with a line containing the league name and the number of qualifiers for that league, separated by a comma.
  2. This line is followed by fourteen sets of:
    1. A line containing a weight class, followed by...
    2. The qualifiers at that weight. Each qualifier’s line consists of
      • The competitor’s name.
      • His or her year in school (zero if information is not available).
      • The name of the school.
      If the competitor is an alternate, his or her name will begin with an asterisk. If there is no competitor available at a weight, the name will begin with BYE (all uppercase) and the school name will be --- (three hyphens).
  3. A line consisting of three or more equal signs indicates the end of a league’s data.

Your program will take this data and build the following data structures:

Your program will then produce the following output:

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.

Notes & Hints

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 and email it to the instructor when you finish.