Path: utzoo!censor!geac!alias!rae%alias@csri.toronto.edu From: rae%alias@csri.toronto.edu (Reid Ellis) Newsgroups: comp.lang.perl Subject: Re: Operations on filehandles Summary: use variables for filehandles Message-ID: <738@alias.UUCP> Date: 7 Feb 90 14:48:51 GMT References: <1004@frankland-river.aaii.oz.au> Sender: news@alias.UUCP Reply-To: Reid Ellis Organization: Alias Research -- the cutting edge in JAGGIE technology Lines: 38 pem@frankland-river.aaii.oz.au (Paul E. Maisano) writes: |... if I open a file in a subroutine and use a file handle called |FILE which I open and then close, how do I know I'm not stomping on |another filehandle called FILE which has already been opened somewhere else |in my program. | | ... | |Is there a simple way to do this or must I generate a unique filehandle name |on each invocation ? 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. Reid --- "I don't even know what street Canada is on" -- Al Capone Reid Ellis 264 Broadway Avenue, Toronto ON, Canada M4P 1V9 rae%alias@csri.toronto.edu || +1 416 487 1383 "I don't even know what street Canada is on" -- Al Capone Reid Ellis 264 Broadway Avenue, Toronto ON, Canada M4P 1V9 rae%alias@csri.toronto.edu || +1 416 487 1383