in reply to Re: Re: formatting newline characters
in thread formatting newline characters
It's true that access prefers \r\n, but only if you're on a unix. On windows, access prefers the \n. The reason for the confusion is that \n isn't really a character, it's a LOGICAL newline. From perlport:
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.
So in order to fix unix newlines to dos newlines, you need to ADD a LF to the end of lines:
my $LF = "\012"; while (<>) } s/$/$LF/g; }
-- Dan
|
|---|