On Monday, April 15, 2002, at 01:17 PM, Alex S wrote: > I think he was just "stirring up" debate on the lack of "my" in > the latter > example. Ie, not declaring variables (and thus scope).
There are no scoping problems with that example. The $_ variable is automatically localized. > On Mon, 15 Apr 2002 12:39:37 +1000, Ken Williams wrote: > >>>> Code B: >>>> foreach (@array) { $_++ } >>> >>> >>> Do my vars suddenly spring into existence now? >> >> Huh? I'm not sure what you mean. If you don't indicate an >> iterator variable, $_ will be used, and its scope will be >> localized to the execution block of the 'foreach' loop. >> >> See the section on "Foreach Loops" in the 'perlsyn' man page for >> the details. -Ken