in reply to 'or' versus '||' - Unexpected Results
You have three areas of confusion. First, is the context in which operands are evaluated.
| is a math operation. It requires two numbers on which to operate. Its operands are evaluated in scalar context.
|| is a conditional operator. It requires its LHS to be true of false. Its LHS operand is evaluated in scalar context. Since it doesn't need to inspect the RHS, the context in which the operator is evaluated is propagated to its RHS operand.
or is identical to || except in precedence.
You also seem to have a problem understanding the different precedence of the || and or operators.
my @list0 = x() || (1,2,3); means my @list0 = ( x() || (1,2,3) );
my @list1 = x() or (1,2,3); means ( my @list0 = x() ) or (1,2,3);
Finally, it appears that bbox returns something different in scalar context ([51,3,102,55]) than in list context ((51,3,102,55)).
It is not only functioning as documented, but as intentionally and thoughtfully designed.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: 'or' versus '||' - Unexpected Results
by ikegami (Patriarch) on Jun 24, 2008 at 16:45 UTC | |
|
Re^2: 'or' versus '||' - Unexpected Results
by cmv (Chaplain) on Jun 24, 2008 at 16:47 UTC | |
by ikegami (Patriarch) on Jun 24, 2008 at 16:58 UTC | |
by kyle (Abbot) on Jun 24, 2008 at 19:47 UTC | |
by massa (Hermit) on Jun 24, 2008 at 18:14 UTC | |
by ikegami (Patriarch) on Jun 24, 2008 at 18:40 UTC | |
by massa (Hermit) on Jun 24, 2008 at 19:57 UTC | |
by massa (Hermit) on Jun 24, 2008 at 17:02 UTC |