XP is just a number | |
PerlMonks |
Re: Why is it uninitialized?by hexcoder (Curate) |
on Dec 20, 2017 at 21:03 UTC ( [id://1205945]=note: print w/replies, xml ) | Need Help?? |
In [Perl Best Practices] from Damian Conway, there is an entry 'Non-Lexical Loop Iterators' in chapter 6 warning about this construct.
Without my, Perl does not use the variable $S4 for the loop, but instead uses a new lexically variable also named $S4. Thats why the first variable $S4 is uninitialized in sub X. So your code behaves like this:
Conway warns to use this construct since its 'behaviour is contrary to all reasonable expectation'. BTW: perlcritic warns about it too.
In Section
Seekers of Perl Wisdom
|
|