Programming in Perl

Homework 4

Input/Output scripts

The first input script is located here. Download this script and put it in your homework directory. You can then run your program with the input from this script like this:
myHW4.pl < hw4sample.txt
For those who don't have experience with redirecting standard input via the shell, I'll explain. The < character tells the shell to open the file on the right of the symbol. It then runs the program on the left. Every time the program asks for input from STDIN, the shell instead grabs the input from the file. So every time you take in one line of text via <STDIN>, the next line of the script file will be read instead of waiting for the user to type anything. Depending on your shell, the input may or may not appear on the screen when the program is run.
The output your program should generate when running this input script is located here. (The output is formatted as HTML, but it will show you what your output should look like.)

This first script will test your program's AddStudent, PrintStudentInfo, PrintAllStudents, and AddGrade functions. It will also attempt to save changes to a file called samplegrades.txt (so make sure you don't have a file named that that you don't want to clobber beforehand).


The second input script is located here This script takes in the grades file generated by the previous script. Run it with your program as follows:
myHW4.pl samplegrades.txt < hw4sample2.txt
This script tests your ParseFile, RemoveStudent, and ChangeGrades functions. It also makes use of some of the other functions, so you should be sure your program works with the first script before attempting this one.

The output your program should generate when running this input script is located here.


Please take note that neither of these scripts tests any of your error checking routines. In other words, these scripts should not produce any errors in your script. Testing your error checking is up to you.