On Wed, 24 Oct 2001, birgit kellner wrote:

> I'm sure this has been covered billion times:
> Until recently, I assumed that the binary operator "||" functions as 
> either-or. Now I read that it evaluates the left side and, if it evaluates 
> true, doesn't care about the right. So if I want to test whether either 
> $one or $two exists, || would be a bad choice:

Yes, || is a short circuit operator, in that it will quit evaluating once
it finds a true statment.

> 
> my $one = "some";
> my $two = "stuff";
> if ($one||$two) { print "yes\n";}
> else { print "no\n";}
> 
> The if-condition would evaluate as true also if both values exist, which I 
> don't want.
> My understanding is that either-or (i.e. excluxive or) on strings would 
> best be done with "xor". Is that correct?

I've never needed to use XOR, but that's how I think it works.

Chris


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

Reply via email to