in reply to Re: Why does assignment change the result?
in thread Why does assignment change the result?
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.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Why does assignment change the result?
by Sixtease (Friar) on May 23, 2007 at 22:14 UTC | |
by tye (Sage) on May 23, 2007 at 22:34 UTC | |
|
Re^3: Why does assignment change the result?
by duff (Parson) on May 23, 2007 at 22:10 UTC | |
by blazar (Canon) on May 23, 2007 at 22:25 UTC |