Newsgroups: comp.lang.perl Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.jpl.nasa.gov (Larry Wall) Subject: Re: Recursive use of iterators Message-ID: <1991Apr9.044920.22700@jpl-devvax.jpl.nasa.gov> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA References: <1991Apr3.233616.11680@uvaarpa.Virginia.EDU> Date: Tue, 9 Apr 1991 04:49:20 GMT In article <1991Apr3.233616.11680@uvaarpa.Virginia.EDU> worley@compass.com writes: : I was writing a recursive function that contained a foreach statement, : so I made sure to localize the array it was iterating over: : : local(@dependencies) = ...; : foreach (@dependencies) {...} : : Somewhat to my surprise, the recursive execution of the loop : interfered with the proper operation of the outer execution. I found : that I have to localize the symbol table entry (if that's how you say : it): : : local(*dependencies); : @dependencies = ...; : foreach (@dependencies) {...} : : This is probably not a bug, but it led me to wonder how you deal with : recursive loops like: : : foreach $i ($a .. $b) {...} That's handled by translating internally to local(@_GEN_1) = ($a .. $b); foreach $i (@_GEN_1) {...} Only when you use a bare array do you get the direct references into the array. That still doesn't say why your original didn't work though... Larry