^M is Carriage Return, which is \r in regexp parlance.
s/\r//;
--
Oh Lord, won’t you burn me a Knoppix CD ?
My friends all rate Windows, I must disagree.
Your powers of persuasion will set them all free,
So oh Lord, won’t you burn me a Knoppix CD ? (Missquoting Janis Joplin)
| [reply] [d/l] |
Just wondering if this is not platform specific. If you bring windows text files to Un*x (using your USB key and not FTP ascii mode for ex.), it's probably what you need (and what the OP needed :). But in general (supposing an ASCII world) why not spell in full i.e s/\015//g;
On the mac, line-endings are ^M and that's the \n escape, isn't?, so my guess is that \r will be different...but I have no mac (yet) and cannot prove it ;)
% stephan@armen (/esc) %
% cat -evnt hi1; echo; perl -lpe 's/\015//g' hi1 | cat -evnt
1 hello world^M wake up^M please$
2 and be good$
1 hello world wake up please$
2 and be good$
hth
--steph
| [reply] [d/l] |
You're right, and I don't have an old Mac to verify this on (OSX uses the Unix line ending convertion afaik). perlport shows the various line termination combinations in an ASCII table.
As the OP referred to ^M not CR or ASCII 13, I could infer that the platform was not an old mac.
--
Oh Lord, won’t you burn me a Knoppix CD ?
My friends all rate Windows, I must disagree.
Your powers of persuasion will set them all free,
So oh Lord, won’t you burn me a Knoppix CD ? (Missquoting Janis Joplin)
| [reply] |
Thanks! that works.
Cheers!
| [reply] |
The dos2unix (which can be found on your local unix-like box) may also be of help to you.
Also most editors silently do the CRLF->CR->LF and back translations without even telling you now (since editors have come to realise that programers ``just don't care what the end of the line is'', and ``can we just get on with coding please?'' -- fickle bunch those coders)
@_=qw; ask f00li5h to appear and remain for a moment of pretend better than a lifetime;;s;;@_[map hex,split'',B204316D8C2A4516DE];;y/05/os/&print;
| [reply] [d/l] [select] |
yeah, *except* if there's a \r missing at least on one line of the
file - fickle bunch those editors ;)
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
| [reply] |