<snip href="perldoc perlport">
ISSUES
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', depend­
ing on whether you're reading or writing.  Unix does the
same thing on ttys in canonical mode.  `\015\012' is com­
monly referred to as CRLF.

Because of the "text" mode translation, DOSish perls have
limitations in using `seek' and `tell' on a file accessed
in "text" mode.  Stick to `seek'-ing to locations you got
from `tell' (and no others), and you are usually free to
use `seek' and `tell' even in "text" mode.  Using `seek'
or `tell' or other file operations may be non-portable.
If you use `binmode' on a file, however, you can usually
`seek' and `tell' with arbitrary values in safety.
</snip>


On Thu, 2002-01-31 at 08:46, Dave Benware wrote:
> Bob Showalter wrote:
> > No. A "\n" in your program is an ASCII linefeed (10) character
> > on either platform.
> 
> So, \n equals a LF, thank you.
> 
> 
> > 
> > What happens on Windows is that when you are reading a file,
> > each CR/LF pair from the file is changed to a single LF char
> > before the data is returned to you. On output, the situation
> > is reversed (LF is translated to CR/LF pair). On UNIX, no
> > such translation is done.
> > 
> > On Windows, if you don't want this translation done, you need
> > to call binmode().
> > 
> > All the poop can be found at:
> > 
> >    perldoc -f binmode
> 
> CR/LF has never been translated to a LF while reading a file
> for me.  If that were true, the whole situation would be
> transparent and I would have never asked the question it seems.
> I didn't see anything about this "translating" in the docs
> on the binmode function.
> 
> Bompa
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
-- 
Today is Sweetmorn the 31st day of Chaos in the YOLD 3168
Or is it?

Missle Address: 33:48:3.521N  84:23:34.786W


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to