Due Tuesday, 10PM, Feburary 3
Create a Perl program named makeAccounts.pl that reads a file containing information about all the students in a course, and which creates an output file containing the definitions of userIDs and passwords for each of the students in that course.
The syntax for invoking the program should be:
makeAccounts.pl courseName inputFile [rotation]
Where courseName is the official course identifier such as "COSC433". The last three characters of courseName should be digits. If they aren't, your program should print an appropriate error message (e.g. "the course name must end in 3 digits") and terminate (You might want to use perldoc to check out the die function for this!). The second argument should be the pathname of the file containing the course information. If the input file does not exist, the program should print an appropriate error message and terminate. The third argument, rotation, is optional. (The optional nature of the argument is indicated by the square brackets. This is the usual syntax for specifying command line format in Unix.) rotation is a non-negative integer that will be used to generate passwords. If the argument is negative, print an appropriate error message (e.g. "the rotation must be a non-negative integer) and terminate. If rotation is not specified, assume it is 0.
The input file contains a single string that consists of the course's student information. The string may start with some whitespace, but will then consist of a sequence of substrings, each of which is an integer, followed by the name of a student (surname, followed by a comma, followed by the rest of the name), followed by the student's ID ('E' followed by 8 digits), followed by a bunch of information about the student. No integers will be in the "bunch of information".
You should create an output file with the same name as the input file. If the input file had a suffix, it should be replaced with the suffix ".passwd" in the output file. So, for example, if the input file was named "class.foo.txt", the output file would be named "class.foo.passwd". If the input file does not have a suffix, just append the ".passwd" suffix to obtain the name of the output file.
The output file should consist of one line for each student in the class. Each line will consist of two (whitespace separated) words, a user ID followed by a password. The userID will be the first 5 characters of the student's surname, appended with the 3-digit course number. The password will be the last 6 digits of the student's student ID, but rotated to the right by the rotation value. For example, if the student ID was E00012345 and rotation was 3, the password would be 345012.
Here is a sample input file. If we run our program using the command line:
makeAccounts.pl cosc433 classList_anon.txt 2
We would expect this output file:
das433 470190 datta433 939313 divve433 454736 feira433 940317 gao433 188735 kroth433 558439 kwan433 635316 liu433 009119 naik433 383798 parla433 230967 rao433 407174 veera433 548436 wang433 778208 wu433 694378 xiang433 927606 xu433 841319 yalam433 118759 yang433 660192
If your program is not given sufficient arguments in the command line, it should print out a useful USAGE string, indicating the appropriate form of the command line.
Submit your program source code electronically via http://caddis.acad.emich.edu/~hwmatt/student/, and submit a hardcopy of your program the next time class meets (Thursday the 5th?).