http://www.perlmonks.org?node_id=1014475


in reply to Re: foreach-loop-local var in sub
in thread foreach-loop-local var in sub

you have changed context and $i is uninitialized within that context and therefor you are going to print zeros
Not exactly true. Try with
foreach (qw(a b)) {
Update: Do not use numbers for testing behaviour, see Re^3: variable declaration question.
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ