Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!snorkelwacker!mintaka!oliveb!pyramid!nsc!taux01!tasu74!crehta From: crehta@tasu74.UUCP (Ran Ever-Hadani) Newsgroups: comp.lang.perl Subject: Passing file handles as parameters Message-ID: <3751@taux01.UUCP> Date: 2 May 90 08:00:34 GMT Sender: netnews@taux01.UUCP Reply-To: crehta@taux01.nsc.com (Ran Ever-Hadani) Organization: National Semiconductor (IC) Ltd, Israel Lines: 31 I have a perl program that keeps many similar output files open simultaniously. I have a single routine which does the formatting of output to all of them. I would love to be able to call the routine with the output file as a parameter. Would this be possible in the future? What I tried do far was this: - I had the routine print to its own file handle OUT, which I attached to the output file; the calling line was open (OUT, ">&$file"); &do_out; This forced me to set all outputs to unbuffered, which I didn't want. - I passed a string containing the filehandle name as a parameter, and called eval to insert it to a print command; This made the program about 15 times slower. - I defined an output format for each of the files which contained a single variable $out_line. This seemed the best sollution. -- Ran my program about 15 times slower than simply copying the damn routine inline without the eval. - ----------------------------------------------- Reply-To: crehta@taux01.nsc.com (Ran Ever-Hadani) Disclaimer: The above is to be attributed to me only, not to any organization. Apology: Bad English. E-mailed spelling and style corrections are welcome.