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: Wed, 3 Nov 2004 22:23:11 -0500 (EST) From: Igor Pechtchanski Reply-To: cygwin AT cygwin DOT com To: Earl Chew cc: cygwin AT cygwin DOT com Subject: Re: Perl binmode problem on text mount In-Reply-To: <41897FF4.1080501@agilent.com> Message-ID: References: <41897FF4 DOT 1080501 AT agilent DOT com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Scanned-By: MIMEDefang 2.39 On Wed, 3 Nov 2004, Earl Chew wrote: > This code used to work on Perl 5.6.1-2 on Cygwin 1.3.10. > > I've now moved to Perl 5.8.5-3 on Cygwin 1.5.11. > > Here is the Perl program: > > binmode STDOUT; > print "Hello\n"; > > 1. Output to file on text mount > > perl foo.pl > foo.txt ; od -c foo.txt > > 0000000 H e l l o \r \n # Perl 5.8.5-3 Cygwin 1.5.11 > 0000000 H e l l o \n # Perl 5.6.1-2 Cygwin 1.3.10 > > 2. Output to file via cat > > perl foo.pl | cat > foo.txt ; od -c foo.txt > > 0000000 H e l l o \n # Perl 5.8.5-3 Cygwin 1.5.11 > 0000000 H e l l o \n # Perl 5.6.1-2 Cygwin 1.3.10 > > Has anyone else experienced the same issue? This is expected behavior. Unless you use raw writes (as "cat" does), the mode of the file (text or binary) is determined *by the program that opens the file*. In the above case, the program is not perl, it's your shell. You can try one of a few things: either set PERLIO to ":raw" (I guess ":unix" should also work) before invoking perl, or make perl open the file itself instead of relying on shell redirection, or use the cat trick, or use a binary mount... Since you mentioned perl-5.6.1, setting PERLIO would probably be the best way to approximate the behavior. For more details on PERLIO, see "man perlrun". Igor -- http://cs.nyu.edu/~pechtcha/ |\ _,,,---,,_ pechtcha AT cs DOT nyu DOT edu ZZZzz /,`.-'`' -. ;-;;,_ igor AT watson DOT ibm DOT com |,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D. '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! "The Sun will pass between the Earth and the Moon tonight for a total Lunar eclipse..." -- WCBS Radio Newsbrief, Oct 27 2004, 12:01 pm EDT -- 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/