develooper Front page | perl.perl5.porters | Postings from October 2003

Re: [perl #24312] \x0a reads as "\r\n" on activestate perl (not on cygwin )

Thread Previous | Thread Next
From:
Nick Ing-Simmons
Date:
October 28, 2003 00:32
Subject:
Re: [perl #24312] \x0a reads as "\r\n" on activestate perl (not on cygwin )
Message ID:
20031028083151.2522.4@llama.elixent.com
Edward Peschko <perl5-porters@perl.org> writes:
># New Ticket Created by  Edward Peschko 
># Please include the string:  [perl #24312]
># in the subject line of all future correspondence about this issue. 
># <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=24312 >
>
>
>This is a bug report for perl from esp5@pge.com,
>generated with the help of perlbug 1.34 running under perl v5.8.0.
>
>
>-----------------------------------------------------------------
>[Please enter your report here]
>
>the following script:
>
>
>open(FD, "> filename");
>print FD "\x0a";
>close(FD);
>
>makes 'filename' have a standard, dos, "\r\n" line, not "\n" as expected.

Sorry - you might expect that, but Win32 users expect "\n" to become "\xd\xa"
(CRLF) when writing disk files. i.e. Win32 defaults to textmode.
This is the way Win32 perl is. You need to add 
  binmode(FD);
before the print to turn this behaviour off.



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About