Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!snorkelwacker!bloom-beacon!eru!luth!sunic!mcsun!hp4nl!ruuinf!piet From: piet@cs.ruu.nl (Piet van Oostrum) Newsgroups: comp.lang.perl Subject: Re: buffering and a news archiver Keywords: perl, news, rkive, buffer, NULL Message-ID: <2739@ruuinf.cs.ruu.nl> Date: 27 Mar 90 09:37:50 GMT References: <814@alias.UUCP> Sender: news@ruuinf.cs.ruu.nl Reply-To: piet@cs.ruu.nl (Piet van Oostrum) Organization: Dept of Computer Science, Utrecht University, The Netherlands Lines: 40 In-reply-to: rae%alias@csri.toronto.edu (Reid Ellis) In article <814@alias.UUCP>, rae%alias (Reid Ellis) writes: `A problem and a program. ` `The problem - ` ` I have a program that archives all of the source groups for me at ` night [comp.sources.*] which uses an 'rc' file in the home ` directory. The program is called 'narc' and the rc file is named ` '.narcrc' and everytime I run narc, which is a perl script, I get ` 8k of NULs appended to the end of my '.narcrc' [which JUST SO ` HAPPENS to be == BUFSIZ].. ` ` close(); ` ` close(); ` `close(); ` `close(); ` close(
); ` close(); ` close(); ` close(); ` close(); All these closes are wrong. You have to say close (FILEHANDLE), not close (). What happens in the case of NARCRC, is that you read an extra line , which apparently reads a new buffer into memory. The buffer is then written out when perl stops. The resulting string is used as an argument for close. I would say that close should accept only filehandles as parameters, not strings. I have no idea what close does with a string parameters. Maybe it is an oversight in perl to accept this. This may well depend on your particular stdio implementation. -- Piet* van Oostrum, Dept of Computer Science, Utrecht University, Padualaan 14, P.O. Box 80.089, 3508 TB Utrecht, The Netherlands. Telephone: +31-30-531806 Uucp: uunet!mcsun!ruuinf!piet Telefax: +31-30-513791 Internet: piet@cs.ruu.nl (*`Pete')