in reply to declaring a common loop variable
Further to 1nickt's post: pritesh_ugrankar: Note that the local scoping (or aliasing) of a for-loop iteration variable is very strong and holds even if you do not declare a separate lexical for each loop:
(But yes, certainly use different variable names as a sanity-saver!)c:\@Work\Perl\monks\nysus>perl -wMstrict -le "my @x = (1, 2); my @y = qw(foo bar); ;; my $z = 'original'; for $z (@x) { printf qq{$z }; for $z (@y) { printf qq{'$z' }; } print $z; } print qq{after all loops: '$z'}; " 1 'foo' 'bar' 1 2 'foo' 'bar' 2 after all loops: 'original'
Give a man a fish: <%-{-{-{-<
|
|---|