Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Removing Carriage returns from text files

by Ven'Tatsu (Deacon)
on Oct 18, 2001 at 06:54 UTC ( #119612=note: print w/replies, xml ) Need Help??


in reply to Removing Carriage returns from text files

Since you are on Windows you will need to binmode() your output handle. If you don't it will automaticly add the CR to your LF every time you output a LF.
open(INFILE, "< input.txt") or die "Failed to open input: $!\n"; open(OUTFILE, "> output.txt") or die "Failed to open output: $!\n"; binmode(OUTFILE); while (<INFILE>) { print OUTFILE }
This code will remove the \r at the end of the line only. If you want to strip all \r's you will need to do s/\r//; imediatly prior to the print statment.

Replies are listed 'Best First'.
Re: Re: Removing Carriage returns from text files
by Kalimeister (Acolyte) on Oct 18, 2001 at 17:39 UTC
    Ven'Tatsu, you are an angel! That works like a charm and is very easy to incorporate into the rest of the manipulation.

    Thanks again for all of your help.
    Kalimeister
Re^2: Removing Carriage returns from text files
by Anonymous Monk on Aug 18, 2017 at 01:33 UTC
    Worked like a charm. Thanks a lot.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://119612]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2021-10-16 18:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (69 votes). Check out past polls.

    Notices?