simpler:
$ perl -E '$x = "foo"; say for $x x= 2'
that compiles to (only relevant part):
BINOP (0x189a938) repeat [1] UNOP (0x189a9c0) null [15] SVOP (0x189aa00) gvsv GV (0x197dac8) *x SVOP (0x189a980) const IV (0x197dae0) 2
while
$ perl -E '$x = "foo"; say for ($x) x= 2'
is actually
BINOP (0xecd938) repeat [1] UNOP (0xecd8f0) null [158] OP (0xecd8b8) pushmark UNOP (0xecd9c0) null [15] SVOP (0xecda00) gvsv GV (0xfb0ac8) *x SVOP (0xecd980) const IV (0xfb0ae0) 2
and
$ perl -E '@x = (@_ = qw( a b )) x= 2'
is
BINOP (0x14b79b8) repeat [4] UNOP (0x14b7970) null [158] OP (0x14b7938) pushmark BINOP (0x14b7a40) aassign [3] UNOP (0x14b7b40) null [158] OP (0x14b7b08) pushmark SVOP (0x13ffc38) const PV (0x159ab28) "a" SVOP (0x13ffbe0) const PV (0x159ab70) "b" UNOP (0x14b7ac0) null [158] OP (0x14b7a88) pushmark UNOP (0x13ffc78) rv2av [2] SVOP (0x13ffcb8) gv GV (0x13de0d0) *_ SVOP (0x14b7a00) const IV (0x159ab58) 2
So pretty much like GrandFather said. Hopefully that answers your question. I don't think it's documented anywhere; see toke.c and perly.y if you want more details. Certainly this behaviour is subject to change without notice.

In reply to Re: ... for (@_) x= 2; by Anonymous Monk
in thread ... for (@_) x= 2; by rsFalse

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.