[ILUG] ^M quickie

From: Michael Turley (samplecode at domain yahoo.com)
Date: Thu 04 May 2000 - 23:52:13 IST


I wrote:
> Does anyone know of a quick way to get rid of ^M
from
> multiple files of the same format?

Here's how to do it in Perl (almost entirely robbed
from Perl Cookbook). I forgot that ^M is equivalent to
\r for perl regex.

#!/usr/local/bin/perl

local $^I = '.old';
local at domain ARGV = glob("*.c");
while (<>) {
s/\r//;
print;
} continue {close ARGV if eof}

=====
Mr. Michael Turley
Gracious winner, Generous lover, All round great guy.

__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/



This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:06:02 GMT