[email]john.andrews1talk21.com[/email] (John Andrews) wrote in message news:<fc134cb0.0308282339.67d992e2posting.google. com>...My guess is something is wrong with the line endings in foo ... I> I have a text file foo. At the end of each line in foo I have
> carriage return and newline characters, i.e. \r\n
> If I do this
> perl -pe 's/NEVERFOUND/NEVERFOUND/g' < foo > bar
> ... then bar contains exactly the same as bar, except
> that extra carriage returns have been added, i.e. each
> line finishes with \r\r\n . Anyone know why this happens,
> and how I can stop it?
> Yours in puzzlement
create my own foo file and ran the above one-liner without
encountering the problem you're describing. But I have run into
similar problems myself. Usually it was caused by a couple of things:
1) When printing out a line in a perl program there's no need to end
lines with a "\r\n" on a Win box. Plain old "\n" will do (\n is
magical in Perl - it will output whatever line endings your OS may
need). This applies only if you're creating foo with a Perl script.
2) "Clean" the source file by opening it in your text editor, copy and
paste everything into notepad, and from notepad copy & paste it back
into a new doent in your text editor. Then save the file, making
sure the save dialog uses your OS's line endings.
If this voodoo doesn't work for you, sorry.
These type of problems are very vexing, but usually the fault lies in
your text editor and the way it is saving files.