From: Shlomi Fish

> On Monday 04 October 2010 14:45:57 Bob McConnell wrote:
>> From: Brandon McCaig
>> 
>> > On Fri, Oct 1, 2010 at 8:26 AM, Bob McConnell <r...@cbord.com>
wrote:
>> >> AKA carriage return, it suggests you have DOS/Windows line endings
>> >> instead of Unix. You can clean them up in the source files with
the
>> >> dos2unix or tr filters. The latter looks something like this:
>> >> 
>> >> $> tr "\r\n" "\n" < bad.pl > good.pl
>> > 
>> > It suggests to me that he has Mac (<=9) carriage returns (\r or
0x0D)
>> > only. As far as I can tell, that Perl one-liner he was asked to run
>> > should have printed all characters < decimal 31 and greater than
>> > decimal 126, of which the 10 or CF in the DOS/Windows newline
should
>> > have been printed as well. It shouldn't be too difficult to write
an
>> > equivalent tr for mac2unix though to compensate.
>> 
>> $> tr "\r" "\n" < bad.pl > good.pl
>> 
>> You can also combine them to do either/or. The first pair takes
>> priority, but the second pair will pick up any left over carriage
>> returns and turn them into extra line feeds.
>> 
>> $> tr "\r\n" "\n" "\r" "\n" < bad.pl > good.pl
>> 
> 
> tr processes one character at a time, so this code won't work.

That's strange. I have been using the first version of this to get rid
of ^M for about 26 years now with no problems whatsoever. I used it on
Eunice (NCR Unix) long before I even knew Perl existed. I didn't think
my memory was that far off.

Bob McConnell

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to