in reply to Re^2: ... for (@_) x= 2; (scalar assignment)
in thread ... for (@_) x= 2;

the list assignment returns the length of the list in scalar context, so
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!

update

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
    I tried compare three of my codes and their outputs. 'x=' seems doing the same in all three cases - it asks '@_' to be a scalar.
      > I tried compare three of my codes

      sorry?

      > x= seems doing the same in all three cases - it asks @_ to be a scalar.

      which is correct and documented.

      Anyway it might be an implementation flow that you sometimes don't get a warning or compilation error, but not a very serious one.

      I don't see the point discussing it further, since you have plenty of possibilities to achieve your goal in a much saner way.

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!