Dirk Bremer wrote:
> 
> Joe,
> 
> Some clarification, the first two arguments are always required. Both the third 
>argument and fourth argument are optional and
> positional. There would be instances where the fourth argument would have a valid 
>value but the third argument would have some type
> of null value to indicate that it would not be used. I have tried passing under, "", 
>'', " ", and ' ' as the third argument and
> testing for its presence and validity. For example, when called like this:
> 
> Depth($Dir,\%Files,'',150000);
> 
> The third argument is a null string. The check:
> 
> if ((@_ > 1) and (defined $_[2])) {$Type = $_[2];}
> 
> equates to being true and sets $Type. The check:
> 
> if ((@_ > 1) and (length($_[2]))) {$Type = $_[2];}
>
> generates the error but seems to equate to false and $Type is not set. 

Yes, but that test is wrong.  It should be

  if ((@_ > 2) and (length($_[2]))) {$Type = $_[2];}

Arrays (unless you changed it explicitly) are zero based.  And you are
checking the length of the array.  So, in your expression, if the array
size is greater than one it might only have two values.

      if (@_ > 1)
          {
          $_[0]  # good
          $_[1]  # good
          $_[2]  # unknown
          }

And since you always pass in at least two values the array the
expression '@_ > 1' would always be true.

I would guess this is your problem.

>I would like someway to test this argument without generating
> an error and generating a false condition in a validity check for the value used in 
>the example.
> 

Even given the above you might want to use the following instead

  Depth($Dir,\%Files,undef,150000);

That might indicate more clearly that no value is being passed in.

This allows you to just test for defined or not and skip all of the
array bounds checking.

    if (defined($_[2])) {$Type = $_[2];}
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

Reply via email to