Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Date: Sat, 13 Sep 2003 09:33:48 +0200 From: "Gerrit P. Haase" Reply-To: "Gerrit @ cygwin" Organization: Esse keine toten Tiere X-Priority: 3 (Normal) Message-ID: <49980560211.20030913093348@familiehaase.de> To: Igor Pechtchanski CC: Peter Westerstrom , cygwin AT cygwin DOT com Subject: Re: perl textmode newline problem In-Reply-To: References: <3F5798C8 DOT 1050806 AT eonreality DOT se> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 >> 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/