Re: Those wretched ^M's!

From: Erwin S. Andreasen (erwin@PIP.DKNET.DK)
Date: 11/13/97

On Thu, 13 Nov 1997, Edward Glamkowski wrote:
> or write a perl script (or a sed script, but I'll leave
> that as an exercise for the reader :)
> #!/usr/local/bin/perl -i.bak
> while (<>) {
>   if /($^M)/ { s/$1//g; }
>   print;
> }

Are you using perl6, with the Telepathy module that somehow does what you
mean, and not what you type? :)

First of all, you must put the condition after if in parens, unless you
are doing the "reverse" if (i.e. print "Hi!\n" if 1;).

Then you use $\r - which doesn't make sense; $ is per definition end of
the matchable string, so there is nothing that can come after it.

Finally, you use a while (<>) { something.. print;} loop, which can be
replaced with two letters: -p in the switches line.

The working solution is a one-liner that should be easy to remember; I
don't bother making a script for it:

perl -pi~ -e 's/\r//g' *.[ch] (or whatever files you want to do this on).

Erwin Andreasen   Herlev, Denmark <>  UNIX System Programmer
<URL:>         <*>           (not speaking for) DDE

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | |

This archive was generated by hypermail 2b30 : 12/08/00 PST