Confusion is the word ... but I think you have just shone a bright light on the matter. Thank you.
So, am I to understand that: the escape \n is equal to \#0A (aka LF) ; and PerlIO translates various forms of new-line to and from \n ; yes ?
That would make perfect sense, and is consistent with the two systems I use (Linux & Winders). I confess that I had suspected that "\n" might be the string "\x0D under some other OS. I feel silly, now. As if Perl could be that quirky ! (Nah.)
In mitigation (and implied suggestions to the documentors), in 'perlport' I find:
Newlines
In most operating systems, lines in files are terminated by newlines. Just what is used as a newline may vary from OS to OS. Unix traditionally uses \012, one type of DOSish I/O uses \015\012, and Mac OS uses \015.
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.
This does say that (at least in DOSish) that \n usually means \#0A and that STDIO is translating things. The word usually leaves room for doubt :-( It would be inconvenient for \n to mean two characters \x0D\x0A, but it could mean \x0D and STDIO could translate new-lines to and from (couldn't it ?).
For me this is not helped by referring to \n as newline, where I believe the name for \x0A to be LF, which leaves open the possibility that the escape \n might be a higher level concept, and mean different things in different places.
The Socket module even provides constants CR, LF, CRLF, etc. Which reinforces the feeling that "\r\n" is unreliable !
FWIW, searching the Perl documentation for "string literal" or "literal" or "escape" or "escape character" or "escape sequence" doesn't come up with much. To find the relevant documentation it's first necessary to understand that what one might think of as a string literal, is in Perl something to do with various forms of 'quote operator' -- which it is, of course, but the learning curve could be less steep.
| [reply] [d/l] [select] |