Not to beat a dead horse any more than necessary, but I want to make one
more point in case anyone is going to use this info. This topic has caused
me much anxiety in the past.
When you write "\012", it is the same as "\n". So in Windows if you don't
use binmode, when outputting "\015\012" you will write out a <cr><cr><lf>
(the \012 will be translated). If you use binmode, it works as expected.
Binmode has no effect whatsoever on Unix, so it's safe to use it all the
time you want special behavior if you care about compatability.
-----Original Message-----
From: Chris Nandor [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 05, 2001 5:27 PM
To: Fernando Trias
Cc: Ron Newman; [EMAIL PROTECTED]
Subject: RE: [Boston.pm] New Line
At 15:33 -0500 02.05.2001, Fernando Trias wrote:
>You get 7. As far as I know, the "\n" -> "\r\n" conversion only occurs when
>you write to a file. The string in Perl is the same and stays the same.
This is true. Same thing on reading a file on Windows ... unless you call
binmode(). Then you get the raw, two-byte, CRLF.
My rule of thumb is this: when dealing with a native filesystem, use \n.
When dealing with network protocols, or a specific filesystem that may have
different newlines than your native newline, use the specific octal values.
So if writing to a file, I would just use "\n". But writing to a file on a
Windows volume mounted on my Linux box, I might use "\015\012". When
writing out HTTP headers, I would use "\015\012". etc.
Use your own rules and thumbs, but this one seems to work well for me ...
--
Chris Nandor [EMAIL PROTECTED] http://pudge.net/
Open Source Development Network [EMAIL PROTECTED] http://osdn.com/