It's true that x has a double nature (repeat string vs repeat list) like .. depending on context (flip flop vs range)
But "combined assignments" like += only allow scalars on the LHS...
See perlop
> These combined assignment operators can only operate on scalars, whereas the ordinary assignment operator can assign to arrays, hashes, lists and even references.
Besides you don't need any assignment
print for @_ x 2 should already work perfectly.
correction print for (@_) x 2 should already work perfectly.
DB<100> @_=1..3 => (1, 2, 3) DB<101> print for @_ x 2 => "" 33 DB<102> print for (@_) x 2 => "" 123123
from perlop
> In list context, if the left operand is enclosed in parentheses or is a list formed by qw/STRING/, it repeats the list.
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!
In reply to Re: ... for (@_) x= 2; (scalar assignment)
by LanX
in thread ... for (@_) x= 2;
by rsFalse
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |