in reply to Re: 'or' versus '||' - Unexpected Results
in thread 'or' versus '||' - Unexpected Results
LIST: 0 | 3 = 3 (number of elements in the array)
That's wrong. For starters, there's no array involved. And before you say "I meant list", there's no list either involved either.
Like I said in my post, "|" operates on scalars, so
my @a = x() | (4,5,6);
is evaluated as
my @a = scalar(x()) | scalar(4,5,6);
And keeping in mind that the comma operator returns it's RHS in scalar context,
my @a = scalar(x()) | scalar(4,5,6); === my @a = scalar(x()) | scalar(5,6); === my @a = scalar(x()) | scalar(6); === my @a = scalar(x()) | 6;
Perl doesn't even bother keeping the 4 and 5 in the compiled code:
>perl -MO=Deparse -e"my @a = x() | (4,5,6);" my(@a) = x() | ('???', '???', 6);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: 'or' versus '||' - Unexpected Results
by pjotrik (Friar) on Jun 25, 2008 at 07:33 UTC |