Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.jpl.nasa.gov (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: Associative arrays as indirect filehandles? Message-ID: <1991Jun14.021325.19342@jpl-devvax.jpl.nasa.gov> Date: 14 Jun 91 02:13:25 GMT References: <1991Jun11.230027.17017@Think.COM> <1991Jun12.115103.7436@Think.COM> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Distribution: na Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 30 In article <1991Jun12.115103.7436@Think.COM> sid@think.com writes: : ... : This did work. Just as I was about to accept the idea of sticking : this in my program, a light shown down from above, the : angels sang in the distance and I UNDERSTOOD. I don't : need to use associative arrays. I can just use a scalar : variable and change the value of the variable. The following : code, which does work as expected illustrates what I mean: : : #!/usr/local/bin/perl : : $filehandle = "opp"; : open($filehandle, ">/tmp/$filehandle"); : $filehandle = "moop"; : open($filehandle, ">/tmp/$filehandle"); : : $filehandle = "opp"; : print $filehandle "Line 1\n"; : $filehandle = "moop"; : print $filehandle "Line 1\n"; : $filehandle = "opp"; : print $filehandle "Line 2\n"; : $filehandle = "moop"; : print $filehandle "Line 2\n"; In 4.0, if you look at the library file cacheout.pl, you'll find some code that lets you have more logical output files than file descriptors. It also uses the filename as the filehandle. Larry