Path: utzoo!attcan!uunet!samsung!brutus.cs.uiuc.edu!jarthur!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: buffering and a news archiver Keywords: perl, news, rkive, buffer, NULL Message-ID: <7564@jpl-devvax.JPL.NASA.GOV> Date: 27 Mar 90 18:38:35 GMT References: <814@alias.UUCP> <2739@ruuinf.cs.ruu.nl> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 50 In article <2739@ruuinf.cs.ruu.nl> piet@cs.ruu.nl (Piet van Oostrum) writes: : 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 (). Use of perl -w would have spotlighted this. : 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. To quote the manual under close: FILEHANDLE may be an expression whose value gives the real filehandle name. This is to support indirect filehandles. If somebody wants the expression to return the next filehandle from a file, that's up to them. I guess it's a case of "Live Free AND Die". Use -w. Larry