in reply to Re: string replace with CRLF
in thread string replace with CRLF

Note the following paragraph from perlport:

Perl uses \n to represent the ``logical'' newline, where what is logical may depend on the platform in use. In MacPerl, \n always means \015. In DOSish perls, \n usually means \012, but when accessing a file in ``text'' mode, STDIO translates it to (or from) \015\012, depending on whether you're reading or writing. Unix does the same thing on ttys in canonical mode. \015\012 is commonly referred to as CRLF.

so one of "\015\012" or "\x0d\x0a" is more reliable across platforms than "\r\n".


DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^3: string replace with CRLF
by ikegami (Patriarch) on Dec 19, 2006 at 21:08 UTC

    MacPerl used to be different, but I was told that is no longer the case. MacPerl was the only exception, so now "\n" is always "\x0A" and "\r" in always "\x0D".

    But if you wanted to be sure, you'd use either
    "\n" without binmode or
    "\x0D\x0A" ("\015\012") with binmode.