Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!ucla-cs!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.jpl.nasa.gov (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: Fall-through exit does not close files. Message-ID: <1991Mar16.013304.1335@jpl-devvax.jpl.nasa.gov> Date: 16 Mar 91 01:33:04 GMT References: <21156@shlump.nac.dec.com> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Distribution: usa Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 25 In article <21156@shlump.nac.dec.com> prakash@aiag.enet.dec.com writes: : I had a perl script in which I opened a file thus : : open(FOO, "| filter"); : : and then did a bunch of writes to FOO. My script exited by just : falling through the end, and the output never got to the filter. : Finally, I put a : : close(FOO); : : at the end of the script, and it worked. Should all filehandles be closed : before exiting? Ordinarily you don't need to do that, unless you want the Perl script to wait for your filter to complete. I just did open(FOO,"| (sleep 15; cat)"); print FOO "howdy\n"; and it worked fine falling off the end of the script. I can't imagine why yours wouldn't work unless you've got #define exit _exit somewhere. Ordinarily C's exit() will flush stdio buffers for you. Larry