Using statement modifiers on a my declaration results in undefined behaviour. So the answer is "don't do that" ;-) (see perlsyn)
"Undefined" means, as always, that anything can happen. The "do { my $x = ... } for (1 .. 3)" version is not such a case (the modifier is on do, not my), so that's why it behaves reasonably.
In reply to Re: Lexical scope vs. postfix loops (perl bug?)
by Tanktalus
in thread Lexical scope vs. postfix loops (perl bug?)
by jh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |