Purl said:
If you would, provide a case example of \r\n not
being the same as \015\012 syntax.
Any time you read a text file on MacOS Classic.
The end-of-line character, \015, is converted to \n on input
and \n on output is converted to \015. If the text file does
happen to contain \012, it is converted to \r on input and
\r on output is converted to \012.
This means that many Perl scripts written for Unix can run
unmodified on MacOS Classic, when it comes to reading and
writing lines in files on the native file system. This also
means that Unix perl scripts doing I/O to TCP/IP sockets have
problems on MacOS Classic if they use the logical end-of-line
character (\n) instead of the ASCII code for linefeed (\012).
References:
perldoc -f binmode
Mac OS, all variants of Unix, and Stream_LF files on
VMS use a single character to end each line in the
external representation of text (even though that
single character is CARRIAGE RETURN on Mac OS and
LINE FEED on Unix and most VMS files). In other
systems like OS/2, DOS and the various flavors of
MS-Windows your program sees a "\n" as a simple
"\cJ", but what's stored in text files are the two
characters "\cM\cJ". That means that, if you don't
use binmode() on these systems, "\cM\cJ" sequences
on disk will be converted to "\n" on input, and any
"\n" in your program will be converted back to
"\cM\cJ" on output. This is what you want for text
files, but it can be disastrous for binary files.
perldoc Socket
Also, some common socket "newline" constants are provided:
the constants "CR", "LF", and "CRLF", as well as $CR, $LF,
and $CRLF, which map to "\015", "\012", and "\015\012". If
you do not want to use the literal characters in your
programs, then use the constants provided here. They are
not exported by default, but can be imported individually,
and with the ":crlf" export tag:
use Socket qw

DEFAULT :crlf);
-Joe