CIS 33A - Programming in PERL

Summer Session 2009 - De Anza College

Assignment-3 (Due Wednesday, 7/22 - at midnight)


Instructions: Write a PERL version of the UNIX wc utility. You will probably want to read the man page for wc and play around with it as a first step in completing this assignment. Your program does not have to provide all of the functionality of this utility, but at a minimum, it must do the following:

  1. Allow the user to specify one, two, or all three of these options: -l, -w, and -c. However, your program does not have to permit the "shorthand" form of these options, i.e., you do not have to handle "-lw" or "-lwc".
  2. Allow the user to provide input via STDIN (redirecting a file from the command line) OR via specifying one or more filenames as invocation arguments.
  3. Output each filename that the user specified via an invocation argument.
  4. Output appropriate totals if more than one file was specified on the command-line.
  5. Format the output exactly the same as the system's wc output.
  6. Use the testwc program to test your program in the same manner as I will be doing.
  7. The two text files used by testwc are constitution.txt and gettysburg.txt.

To hand in your assignment, send me one and only one email with one separate text-file attachment named as specified above. The Subject line should be Perl ASSIGNMENT-3. Please put your name as it appears in De Anza College records in the body of the message.