Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Remove the ^M Character from a Document

by hacker (Priest)
on Jun 03, 2002 at 16:07 UTC ( #171270=note: print w/replies, xml ) Need Help??

in reply to RE: Remove the ^M Character from a Document
in thread Remove the ^M Character from a Document

You might want to try a different substitution character, to lessen the obfuscation on this syntax, such as:
perl -pi.orig -e 's#\r\n#\n#g' filespec
perl -pi.orig -e 's,\r\n,\n,g' filespec
Though ideally, this is more correct:
perl -pi.orig -e 's,\cM,,g' filespec # commas for clarity

Replies are listed 'Best First'.
Re: Remove the ^M Character from a Document
by Abigail-II (Bishop) on Jun 03, 2002 at 16:18 UTC
    The use of the forward slash to delimited regular expressions and replacements has a history of decades - predating the birth of Perl by years. There are no forward slashes in the regular expression that could cause confusion. So, other than a fear of forward slashes, what makes you think use of a forward slash contributes to obfuscation?


      Perhaps hacker actually means that the use of another character could make things easier to read. I remember somewhere some book or other refering to the "leaning toothpick" problem.
        The leaning toothpick syndrome arises if one has to escape forward slashes. No forward slashes need to be escaped.

        Pray tell us, why are comma's or hashes easier to read than forward slashes, especially considering that forward slashes are most commenly used as delimiters, while commas and hashes usually play another role?


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://171270]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2018-03-24 06:42 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (297 votes). Check out past polls.