delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/04/03/14:35:47

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-AuthUser: gerrit:koeln.convey.de
Date: Thu, 3 Apr 2003 21:39:12 +0200
From: "Gerrit P. Haase" <gp AT familiehaase DOT de>
Organization: Esse keine toten Tiere
X-Priority: 3 (Normal)
Message-ID: <23715472465.20030403213912@familiehaase.de>
To: Rolf Campbell <rcampbell AT tropicnetworks DOT com>
CC: cygwin AT cygwin DOT com
Subject: Re: Updated: perl-5.8.0-2
In-Reply-To: <b6fj7f$nss$1@main.gmane.org>
References:
<83040F98B407E6428FEC18AC720F5D732DB804 AT exchange DOT tropicnetworks DOT com>
<121-156912388 DOT 20030401120153 AT familiehaase DOT de> <b6cdqm$v99$1 AT main DOT gmane DOT org>
<182578293952 DOT 20030402073253 AT familiehaase DOT de> <b6fj7f$nss$1 AT main DOT gmane DOT org>
MIME-Version: 1.0

Hallo Rolf,

Am Mittwoch, 2. April 2003 um 23:03 schriebst du:

> Gerrit P. Haase wrote:
>> Hallo Rolf,
>> Am Dienstag, 1. April 2003 um 18:13 schriebst du:
>>>Gerrit P. Haase wrote:
>>>>Rolf schrieb:
>>>>>So, is this a cygwin perl problem?  Or has the stock perl decided
>>>>>to only work with magic ENV variables?
>>>>
>>>>I don't see the problem in the latest Perl (5.9.0) and I'm trying to
>>>>figure out how it can be fixed, in the meantime, please try to use the
>>>>magic PERLIO=perlio setting for your environment.
>>>>Gerrit
>>>Ok, using PERLIO=perlio, but I'm still having a problem (which worked in 
>>>the previous version of Perl).

>>>TEST.PL:
>>>1:#!/bin/perl
>>>2:$/ = "\r\n";
>>>3:
>>>4:open( LOG, "<in" ) ||
>>>5:  die "Could not open log.\n";
>>>6:binmode LOG, ":crlf";
>>>7:
>>>8:$in = <LOG>;
>>>9:print $in;
>> 
>> 
>>>in (od -c in):
>>>0000000   a   b   c  \r  \n   d   e   f  \r  \n
>>>0000012
>> 
>> 
>>>This is on a BINMODE mount.  This script outputs "0000000   a   b   c 
>>>\n   d   e   f  \n".  If I go back to prev Perl, OR remove line#2 OR 
>>>remove line#6, then it outputs "0000000   a   b   c  \n"
>> 
>> 
>> 1. No PERLIO setting:
>> 
>> $ od -c in
>> 0000000   a   b   c  \r  \n   a   b   c  \r  \n
>> 0000012
>> 
>> $ ./crlf.pl 2>&1 | tee log.in
>> abc
>> abc
>> 
>> $ od -c log.in
>> 0000000   a   b   c  \r  \n   a   b   c  \r  \n
>> 0000012
>> 
>> 2. PERLIO=perlio:
>> 
>> $ export PERLIO=perlio
>> 
>> $ ./crlf.pl 2>&1 | tee log.in
>> abc
>> abc
>> 
>> $ od -c log.in
>> 0000000   a   b   c  \n   a   b   c  \n
>> 0000010
>> 
>> 
>> 3. PERLIO=raw:
>> 
>> $ export PERLIO=raw
>> 
>> $ ./crlf.pl 2>&1 | tee log.in
>> abc
>> abc
>> 
>> $ od -c log.in
>> 0000000   a   b   c  \n   a   b   c  \n
>> 0000010
>> 
>> 4. PERLIO=stdio:
>> 
>> $ export PERLIO=stdio
>> 
>> $ ./crlf.pl 2>&1 | tee log.in
>> abc
>> abc
>> 
>> $ od -c log.in
>> 0000000   a   b   c  \n   a   b   c  \n
>> 0000010
>> 
>> 5. PERLIO=:
>> 
>> $ export PERLIO=
>> 
>> $ ./crlf.pl 2>&1 | tee log.in
>> abc
>> abc
>> 
>> $ od -c log.in
>> 0000000   a   b   c  \r  \n   a   b   c  \r  \n
>> 0000012
>> 
>> 
>> Gerrit

> Ok, so you get the same results as me.  They are both wrong.  The script 
> should only print the first line.

> I just tried something, I made a file like this: "0000000   a   b   c 
> \r  \r  \n   d   e   f  \r  \r  \n".  Then the perl script shows only 
> the first line.

> In 5.6: setting 'binmode LOG, ":crlf";' would set the line-separator to 
> "\r\n".
> In 5.8: setting 'binmode LOG, ":crlf";' sets the line-separator to "\r" 
> + $/.  So, given that I've already set the line-separator to "\r\n" it 
> ends up as "\r\r\n" for that file.

> Does anybody have access to a U/Linux machine with perl 5.8 on it?  Can 
> they run that test script on it?  I'd like to know if this is only a 
> problem with cygwin-perl or with perl in general.


What about removing line #6 and let Perl do the conversion:

1.
$ export PERLIO=raw

$ ./crlf.pl 2>&1 | tee log.in
abc

$ od -c log.in
0000000   a   b   c  \r  \n
0000005

2.
$ export PERLIO=perlio

$ ./crlf.pl 2>&1 | tee log.in
abc

$ od -c log.in
0000000   a   b   c  \r  \n
0000005

3.
$ export PERLIO=stdio

$ ./crlf.pl 2>&1 | tee log.in
abc

$ od -c log.in
0000000   a   b   c  \r  \n
0000005

4.
$ export PERLIO=

$ ./crlf.pl 2>&1 | tee log.in
abc
abc

$ od -c log.in
0000000   a   b   c  \r  \n   a   b   c  \r  \n
0000012

5.
$ export PERLIO=unix

$ ./crlf.pl 2>&1 | tee log.in
abc

$ od -c log.in
0000000   a   b   c  \r  \n
0000005


That is what PERLIO is made for.
See perldoc perlio for the details.


Gerrit
-- 
=^..^=


--
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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019