On Mon, Sep 30, 2002 at 03:50:00PM +0800, [EMAIL PROTECTED] wrote:
> I found my mistake: I misread the line number in the error message. DOH!!!
> The complaints were related to the block that prints individualized error
> messages:

Ok, I'm glad you solved your problem.

 
> <CODE>
> unless (defined $directory && defined $comment && defined $max_rows &&
> defined $max_cols && defined $lg_dim && $lg_dim =~ m/[1-9][0-9]?/ &&
> (!defined $saturation || abs($saturation) < 100)) { 
> 
>  print "Specify a directory to scan (e.g., --directory /etc)\n" unless
>       $directory;
> 
>  print "Provide a comment for the photos (e.g., --comment foobar)\n" 
>       unless $comment;
> 
>  print "Specify the number of rows and columns in the indexes (e.g., 
>       --cols 5 --rows 5)\n" unless ($max_rows && $max_cols);
> 
>  print "Specify a number between -99 and 99 for the image saturation value
>       (e.g., --saturation -50)\n" unless (abs($saturation) < 100);
> 
>  print "Specify a number between 1 and 99 for the images\' final size as a
>       percentage of the beginning size (e.g., --largedim 75)\n" unless
>       ($lg_dim > 0 && $lg_dim < 100);
> 
>  exit;
> }
> </CODE>

While this works, typically the way I do it is something along the lines of:

    usage("Specify a directory to scan ...\n") unless defined $directory;
    usage("Provide a comment for the ...\n")   unless defined $comment;

and so on, where usage() is a subroutine that will print out the message
specified, as well as some basic usage information.

The point being, you don't have to test the variables multiple times.  There
is a disadvantage in that the errors will not all be printed out if there
are multiple problems.

I also usually stick my options into a hash, such as %opts, too, but that's
somewhat tangential.


Michael
--
Administrator                      www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

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

Reply via email to