Hello, All:

I'm testing to determine that a list of variables has been set and 
am baffled by how this conditional is evaluating:

CODE SNIPPET:
GetOptions(
        'comment=s'     => \$comment,           # Req'd arg
        'directory=s'   => \$directory,         # Req'd arg
        'rows=i'        => \$max_rows,          # Req'd arg
        'cols=i'        => \$max_cols,          # Req'd arg
        'saturation:i'  => \$saturation         # Optional arg
);

unless (defined $directory && defined $comment && defined $max_rows && 
  defined $max_cols && (!defined $saturation || abs($saturation) < 100)) {
    # Print error messages
  }

WHAT'S HAPPENING:
Without setting $saturation...
 A. Everything works just fine if all of the *required* variables are set.
 B. Perl complains 'Use of uninitialized value in abs' if any of the 
    *required* variables are not set.

WHAT I EXPECT TO HAPPEN:
Without setting $saturation...
  I thought that evaluation of the conditional would stop at the first 
   occurence of an undefined variable and that (!$defined $saturation ||
   abs($saturation) < 100) would _not_ be evaluated i.e., The abs() 
   portion of the test would not be performed.

HOW CAN I:
  1. Check that each of the required variables has been set *and*then*
  2. Check the value of $saturation _only_if_it_has_been_set_?

-- 
Eric Pretorious
Sunnyvale, CA


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

Reply via email to