John W. Krahn wrote:
<snip>
>>however I am unclear what the following is (or how
>>Perl determines it, though this is less important for now if it will
>>make my head hurt),
>>
>>if ( &call_sub_like_this ) {
>> do something cool here....
>>}
>>
>>Is this void because I am not assigning the value to something?
>
>
> No, this is a scalar (boolean) context. The value that the function
> returns is used to determine whether or not to run the code in the if
> (or unless or while or until) block.
>
This makes sense. How about in this case:
if ( 1 > my_sub_that_returns ) {
# do something cool.....
}
It seems like this case could go either way, that is, in some cases your
function could simply be returning a scalar value, say 0 for a failure
in the sub or something, or it could be returning a list (array) that
you are then wanting to check the length of to determine if you want to
"do something cool..." which I realize is just a scalar in array's
clothing, however, can the wantarray know this before it returns?
Obviously this is an unusual case, and you could always just store the
return value to whichever you wanted it to be and the compare, but it is
an interesting function.
http://danconia.org
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]