* Re: perl textmode newline problem
[not found] <3F5798C8.1050806@eonreality.se>
@ 2003-09-04 20:27 ` Igor Pechtchanski
2003-09-13 7:27 ` Gerrit P. Haase
0 siblings, 1 reply; 2+ messages in thread
From: Igor Pechtchanski @ 2003-09-04 20:27 UTC (permalink / raw)
To: Peter Westerstrom; +Cc: cygwin, cygwin-apps
Peter,
Cygwin-apps is a wrong mailing list for your query. The appropriate list
is <cygwin at cygwin dot com>. I've redirected it there and set the
Reply-To: field correspondingly. Please remove <cygwin-apps at cygwin dot
com> from further discussion on this topic. Also, please search the
archives of <cygwin at cygwin dot com>, as they contain the solution to
your problem (in some recent postings). The archives could be accessed at
<http://cygwin.com/ml/cygwin/>.
Igor
On Thu, 4 Sep 2003, Peter Westerstrom wrote:
> I can't get perl to write files in text mode with correct line feeds.
>
> My perl program:
> #!/usr/bin/perl
> open(F, "> test.txt") or die "can't open file";
> print F "Foo\n";
> print F "Bar\n";
> close(F);
>
> Outputs newlines as 0x0A.
>
> But my C program:
> #include <cstdio>
> int main(int argc, char** argv)
> {
> FILE *fp = fopen("test3.txt", "w");
> fprintf(fp, "Foo\n");
> fprintf(fp, "Bar\n");
> fclose(fp);
> return 0;
> }
>
> Writes newlines as 0x0D 0x0A. Same output dir.
>
> All my mounts is in textmode. CYGWIN is empty. I'm using perl 5.8.0-5
> and cygwin 1.5.3-1.
> I recently upgraded cygwin and got this behavoiur. Before it was
> correctly outputting text with 0x0D 0x0A.
>
> What can be the problem? A bug in perl? By design change in cygwin perl?
>
> Peter Westerstrom
> peterw@eonreality.se
--
http://cs.nyu.edu/~pechtcha/
|\ _,,,---,,_ pechtcha@cs.nyu.edu
ZZZzz /,`.-'`' -. ;-;;,_ igor@watson.ibm.com
|,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D.
'---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow!
"I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster." -- Patrick Naughton
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: perl textmode newline problem
2003-09-04 20:27 ` perl textmode newline problem Igor Pechtchanski
@ 2003-09-13 7:27 ` Gerrit P. Haase
0 siblings, 0 replies; 2+ messages in thread
From: Gerrit P. Haase @ 2003-09-13 7:27 UTC (permalink / raw)
To: Igor Pechtchanski; +Cc: Peter Westerstrom, cygwin
Peter,
>> I can't get perl to write files in text mode with correct line feeds.
>>
>> My perl program:
>> #!/usr/bin/perl
>> open(F, "> test.txt") or die "can't open file";
>> print F "Foo\n";
>> print F "Bar\n";
>> close(F);
>>
>> Outputs newlines as 0x0A.
>>
>> But my C program:
>> #include <cstdio>
>> int main(int argc, char** argv)
>> {
>> FILE *fp = fopen("test3.txt", "w");
>> fprintf(fp, "Foo\n");
>> fprintf(fp, "Bar\n");
>> fclose(fp);
>> return 0;
>> }
>>
>> Writes newlines as 0x0D 0x0A. Same output dir.
Please use the PERLIO layers, due to problems with PERLIO and
binmode() in perl I patched perl to default to PERLIO=unix, you can
override this by setting PERLIO in your environment to PERLIO=crlf
which will push the CRLF layer on top, perl will do conversion of \n
to \r\n automatically then.
$ ./perl_newline.pl
$ od -c test.txt
0000000 F o o \n B a r \n
0000010
$ export PERLIO=crlf
$ ./perl_newline.pl
$ od -c test.txt
0000000 F o o \r \n B a r \r \n
0000012
Gerrit
--
=^..^=
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-09-13 7:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <3F5798C8.1050806@eonreality.se>
2003-09-04 20:27 ` perl textmode newline problem Igor Pechtchanski
2003-09-13 7:27 ` Gerrit P. Haase
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).