our $x = 1; for (1, 0) { print "$x "; local $x = 2 if $_; print "$x "; } print "$x\n"; __END__ 1 2 1 1 1