in reply to Bizarre Results when Creating a Closure

sub something { my $i = whatever; ... sub { closure involving $i } }
Each time this closure is evaluated it gets the version of $i from the current invocation of something, which is a different $i each time. But
for my $i (@some_values) { ... sub { closure involving $i } }
doesn't work the same way because each iteration you're getting the same variable $i with a different current value; it's not actually a different variable each time through.

The fact that Perl lets you create closures around variables that can be subsequently altered is nice in some ways, but it can catch one off guard.