Path: utzoo!attcan!uunet!aplcen!samsung!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: Operations on filehandles Message-ID: <7027@jpl-devvax.JPL.NASA.GOV> Date: 8 Feb 90 19:50:14 GMT References: <1004@frankland-river.aaii.oz.au> <738@alias.UUCP> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 25 In article <738@alias.UUCP> Reid Ellis writes: : Don't forget that you can use variables for filehandles. I ran into : the recusion problem myself and found that you couldn't have "local" : filehandles, so the way I got around this was as follows: : : $input = "recursion00"; : : sub recur : { : $input++; : open($input, "filename"); : if(condition) { &recur(); } : close($input); : $input--; : } : : Or something along those lines.. This will give you filehandles with : names like recursion01, recursion02, recursion03 etc. Note that I : wrote the above off the top of my head, but you get the idea. That's the idea, but $input-- isn't magical, so it'll wipe out the value of $input, turning it into a -1. The when you return from the recursion you'll try to close filehandle '-1'. Larry