in reply to (tye)Re: printing \n to a file
in thread printing \n to a file

To avoid this confusion entirely, never use \n unless you are referring to the ASCII newline sequence, whatever that may be on your specific OS. If you truly want a binary ^M or ^J, consider using the \cM or \cJ codes.

Replies are listed 'Best First'.
(tye)Re2: printing \n to a file
by tye (Sage) on Oct 17, 2000 at 01:19 UTC

    This makes sense to me as a self-documenting code practice (documenting what intent the programmer had when sending that newline to a file). However, I'd like to note that it won't fix the problem since, just like "\n" is silently turned into "\r\n" under Windows, "\cJ" will silently be turned into "\cM\cJ", since these are identical strings under Win32 (and most Perl platforms). In MacOS, "\n" is "\cM" and "\r" is "\cJ".

            - tye (but my friends call me "Tye")