CSCI 431 Homework 4

time due submission file
9:00 AM Wednesday 20 September, 2006 csci/431/HW4/

Once again

This assignment is really a repeat of Homework 2 except that this time you should correct all the mistakes noted on your returned Homework 2 assignment.

The assignment

Download the starter Perl script and look it over. It's a script that reads lines from standard input and matches them against regular expressions, written in Perl's fine syntax.

Presently, the program reads a line and will print an 'A' if the line contains the string 'CSCI' and will print a 'B' if the line, in entirety, mathes the regular expression C*S*C*I*.

Your task is to add more regular expression matches. You may not use other control structures, such as conditional statements or additional variables, to solve this problem. It has to be a pure regular expression match.

The table below explains what your program should be looking for and which letter it prints when if finds what it is looking for.

A The string CSCI occurs anywhere within the input line.
B The regular expression C*S*C*I* matches the line.
C Within the line are 11 characters that could be a Social Security number (three digits, hyphen, two digits, hyphen, four digits).
D The line contains both of the strings 'UNCA' and 'WCU'. By the way, this would include a string with WCUNCA.
E The line contains no periods.
F The line contains exactly three periods.
G The line consists of a legal Java floating point number with no surrounding blanks.
H The line contains exactly five words.
I Every 'A' that appears within the line is followed by a 'B'.
J Every 'A' that appears within the line is preceded by a 'B'.

A bit more about turning it in

If you return your graded Homework 2 in class by 20 September, I won't regrade those you got correct on the first attempt.