COSC 146
Program # 6 - The Last Program!

What to do:

You are to write a perl script that will do some simple formatting of text files. There are two versions of this assignment. Version 1 will be worth 25 out of 25 points, version 2 will be worth 30 out of 25 points (earn extra points on those older programs!!).

Suppose a file called poem.txt contains the following text:

                 Mary had       a little    lamb
    Whose fleece was      white as      snow
                        and everywhere that Mary went
The Lamb was sure to go.

Next, suppose our program is called "format.pl". Then typing

$format poem.txt output.txt

would create an output file called output.txt. Please note , we use the dollar sign to represent the operating system prompt (we don't type it, the computer does).

Version 1 output (note left justification)

Mary had       a little    lamb
Whose fleece was      white as      snow
and everywhere that Mary went
The Lamb was sure to go.

Version 2 output (note left justification and elimination of extra white space between words)

Mary had a little lamb
Whose fleece was white as snow
and everywhere that Mary went
The Lamb was sure to go.

Some requirements of your program:
1) You may not use I/O redirection. Instead, your program must get the required file names from the command line.
2) Your program should issue a warning and terminate if the user does not specify two file names on the command line. The warning issued should inform the user of the proper invocation of the program.
3) Your program should issue a warning and terminate if one of the followinf conditions is true:
       - the input file name does not exists
       - the output file name already exists
In either case of 3), the program should indicate precisely what the error is before terminating.