A list in scalar context is its rightmost element, an array in scalar context is its size.
You're right of course. But then you got me thinking... why does the ()= trick work? It is supposed to put its rhs in list context and then is generally put back in scalar context to get the length of a generated list... Is it special cased?
print scalar(()=eval { wantarray ? qw/foo bar baz/ : 1 });
(This prints 3 of course.)
In reply to Re^2: Why does assignment change the result?
by blazar
in thread Why does assignment change the result?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |