in reply to Re: Trouble with newlines
in thread Trouble with newlines
And It would seem that this translation happens between perl and the OS. That is, $/ is "\n" on windows.
Provided you have the file open in text mode, that is :-) update: that's when the translation happens, I mean. $/ doesn't change when you switch to binary mode.
In any case this behaviour (probably not coincidentally) is exactly the same for C:
The C programming language provides the escape sequences '\n' (newline) and '\r' (carriage return). However, contrary to popular belief, these are in fact not required to be equivalent to the ASCII LF and CR control characters. The C standard only guarantees two things:1. Each of these escape sequences maps to a unique implementation-defined number that can be stored in a single char value.
2. When writing a file in text mode, '\n' is transparently translated to the native newline sequence used by the system, which may be longer than one character. (Note that a C implementation is allowed not to store newline characters in files. For example, the lines of a text file could be stored as rows of a SQL table or as fixed-length records.) When reading in text mode, the native newline sequence is translated back to '\n'. In binary mode, the second mode of I/O supported by the C library, no translation is performed, and the internal representation of any escape sequence is output directly.
|
|---|