in reply to Re: A 'strange' character("^M") of contrasting color appearing unexpededly at the end of lines of a unix file. How can it be removed?
in thread A 'strange' character("^M") of contrasting color appearing unexpededly at the end of lines of a unix file. How can it be removed?
You may have an intention error in your while(<FILE>) loop. Right now, you're testing if the string ends with a \r and then you're removing the first occurrence of it. If your string is "Hello \rthere\r\n", your code would print "Hello there\r\n" to DST.
If I understand your intention correctly, I would replace the while loop with the following:
while (<FILE>){ s/\r$//; print DST $_; }
If you want to get rid of all occurrences of \r in the line, you could just say:
while (<FILE>){ s/\r//g; print DST $_; }
|
|---|