COP4342 - Spring 2006

Assignment #3: Writing a head program in Perl

Objectives: Learn about scalars, i/o, and environmental variables in Perl.

Instructions: Your assignment is to write a head-type program in Perl. Your program should be called head.pl. Like the regular head program, it should scan for a -NUMERIC argument to see how many lines to display from each file. It should then look to see if any files are on the command line, and then show the head of each those files. If there are no explicit files on the command line, your program head.pl should then use standard input for its input. If there are multiple files on the command line, then please use the same formatting convention as head uses with its ==> FILENAME <== separator lines. Finally, just show a "usage" message if you find a -h option, and exit immediately from the program with a status 0.

In all of your Perl files, please use invoke Perl with -w, and please include the pragma use strict;. Please comments indicating when the program was created, who created it, and the purpose of the program. Finally make sure that all exits from the program have an appropriate value, including falling through the main portion of the code.

Submission: Submit head.pl as an attachment to langley@cs.fsu.edu via e-mail before the beginning of class on Friday, September 29.