Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: extra line mystery Message-ID: <8613@jpl-devvax.JPL.NASA.GOV> Date: 5 Jul 90 23:19:20 GMT References: Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Distribution: comp.lang.perl Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 17 In article m1dib00@fed.frb.gov (Douglas I. Battenberg) writes: : The following script reads a file, edits some lines, and prints the whole : thing back into a new file. The problem is the output file ends up with an : extra blank line at the end. If I count lines and print the array with a : for loop, I get the correct number of lines. I've monitored this with the : debugger but cannot see where the extra line is coming from. What am I : missing here? : : #! /usr/bin/perl : : $\="\n"; # set automatic newline for print statements If you don't want a newline at the end, then you don't want to set $\ to a newline. In general, avoid setting $\ (and $,), since they're mostly there to emulate awk. Larry