I invariably write:
for my $i (0..3) {
so I am reminded of the scope of the loop variable and am not tempted to think of it having larger scope.
A very good rule to follow is to always declare lexical variables in the smallest scope possible which precludes declaring declaring loop variables outside the for loop scope
In reply to Re^4: Lexical closures
by GrandFather
in thread Lexical closures
by spurperl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |