in reply to Re^2: ... for (@_) x= 2; (scalar assignment)
in thread ... for (@_) x= 2;
DB<114> $l = ( @a = qw/a b/ ) => 2
So it's not the same code!
The difference between your code and my example is that there is no explicit variable (like $l) used here, but somehow it's still possible to change it.
Maybe it's a side effect of for ? I dunno.
I'd prefer a Can't modify warning here too!
But it's still a very peculiar construction, so I'm not surprised if this edge case wasn't covered.
HTH!
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!
More insights:
... it's not the temporary scalar which is modified but the resulting list in brackets
DB<121> print "$_\n" for ($a=666) x= 2 666 666 => "" DB<122> $a => 666
According to the already cited documentation of "combined assignments" this shouldn't be possible, b/c its a list operation.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: ... for (@_) x= 2; (scalar assignment)
by rsFalse (Chaplain) on Dec 29, 2015 at 14:15 UTC | |
by LanX (Saint) on Dec 29, 2015 at 14:20 UTC |