I am a true perl newbie. I am supposed to:

Write a program that finds lines in an input file and copies them to an 
output file . The program takes the following arguments:

   an input file name (a mandatory argument)
   an output filename (an optional argument, set to STDOUT if omitted), 
   a starting position number that marks the beginning of the offset (an      
   optional argument, set to the beginning of the input file if omitted) 
   an ending position number that marks the end of the offset (an optional    
   argument, set to the end of the input file if omitted)

If any mandatory argument is omitted or the command is followed by a help 
switch, your program prints out a usage on the screen (Hint: use assert.pl to 
verify the conditions).

For example, 
- If the user types:

     $ seeklines in Infile out Outfile starting 3 ending 10

Your program will find the 3rd line through 10th line in Infile, and copy 
them to Outfile 

- If the user types:

  $ seeklines in Infile 

Your program will copy the entire Infile to STDOUT.

- If the user types:

  $ seeklines in Infile starting 10

Your program will copy from 10th line through the last line in Infile to 
STDOUT.

- If the user types:

    $ seeklines

or

  $ seeklines h

Your program will respond something like:

  $ Usage: seeklines [-in Input] [-out Output] [-starting StartOffset]
             [-ending EndOffset] 

Use one of the Getopt functions to parse the command-line arguments. For 
details on the usage of Getopt functions, type the following commands:

    $ perldoc Getopt::Std
    $ perldoc Getopt::Long

Take into account the following conditions:
The input file should exist.
If the output file does NOT exist, create one. If exists, append the output 
to the file. What if the end offset is smaller than the start offset number? 
What if either or both of the offset numbers are out of boundary?





-- 
-it does make a difference-
           -michael-

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to