No. The for has the lowest of priorities.
$_++ and say for 1..2;
is not equivalent to
$_++ and ( say for 1..2 );
That's not even legal. The original statement is indeed equivalent to
( $_++ and say ) for 1..2;
| [reply] [d/l] [select] |
it seems to me that for part 2 you are 'say'ing the for loop and thus $_ will be the constant 1 then 2.
Thanks for your thoughts, but the parsing you suggest is not quite right:
$ perl5.10 -MO=Deparse,-p -E 'say for 1..2'
BEGIN {
$^H{'feature_say'} = q(1);
$^H{'feature_state'} = q(1);
$^H{'feature_switch'} = q(1);
}
;
say($_) foreach (1 .. 2);
-e syntax OK
That is, say for ... is understood as say($_) for .... The problem is, unfortunately, much sillier than that: for aliases $_, so I wasn't incrementing the variable that I thought I was incrementing! | [reply] [d/l] [select] |