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
From:
Gisle Aas
Date:
October 27, 2003 23:55
Subject:
Re: [perl #24312] \x0a reads as "\r\n" on activestate perl (not on cygwin)
Message ID:
lrn0bl7q6n.fsf@caliper.activestate.com
Edward Peschko (via RT) <perlbug-followup@perl.org> writes:

> the following script:
> 
> open(FD, "> filename");
> print FD "\x0a";
> close(FD);
> 
> makes 'filename' have a standard, dos, "\r\n" line, not "\n" as expected.
> this is only in the activestate perl; it doesn't exist in the cygwin port.

The string "\x0a" is the same as "\n" and "\n" is automatically
translated to "\r\n" on Windows.  If you don't want this you need to
binmode() the filehandle.

Regards,
Gisle

Thread Previous


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