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: Sun, 4 Aug 2002 20:53:49 +0800 From: Greg Matheson To: cygwin AT cygwin DOT com Subject: perl-5.8.0 and \n Message-ID: <20020804205347.A66682@ms.chinmin.edu.tw> Mail-Followup-To: cygwin AT cygwin DOT com References: <20020725155026 DOT G37421 AT ms DOT chinmin DOT edu DOT tw> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20020725155026.G37421@ms.chinmin.edu.tw> I tried to run my perl script checking 5.6.0's treatment of binary and text mode mounts on a Windows 2000 machine, but had trouble with mount, and I gave up. With the new 5.8.0, IO has layers and old programs writing to files on binary mode mounts will be broken by the new default crlf layer for Win32-like systems (which includes cygwin) unless they also specified binmode. I tried using the open pragma, use open IO => $layer; to set the default layer, but although the pragma is supposed to be lexically scoped, I couldn't change the default within a foreach loop. So I set the PERLIO environmental variable and ran this script on Windows 98 and Windows 2000: #!/usr/bin/perl -w foreach my $modefile ( '/binary/file', '/text/file' ) { my $string = ''; open O, ">$modefile" or die $!; print O "123\n567\n"; close O; open I, $modefile or die; while ( ) { $string .= $_; } print "\t\tString: @{[length($string)]} File: @{[-s $modefile]}"; close I; unlink $modefile; } These are the results: Underlying binary mode Underlying text mode PERLIO=raw String: 8 File: 8 String: 8 File: 8 PERLIO=unix String: 8 File: 8 String: 8 File: 8 PERLIO=stdio String: 8 File: 8 String: 10 File: 10 PERLIO=perlio String: 8 File: 8 String: 8 File: 8 PERLIO=crlf String: 8 File: 10 String: 8 File: 10 It seems 5.8.0 is nullifying the distinction between binary and text mounts. Only stdio, the original C library, gives different results for the 2 modes. I think I am coming round to the MS idea that writing CRs to text files is "natural" :-) This way, porting from Unix perl programs is easier, at least if you are running 5.8.0. No binmodes sprinkled through files. -- Greg Matheson Learn a third language and Chinmin College be born again, again. Taiwan Penpals Archive -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/