delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/03/08/20:50:10

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Date: Thu, 8 Mar 2001 17:48:56 -0800 (Pacific Standard Time)
From: Jason Tiller <jtiller AT sjm DOT com>
To: <cygwin AT cygwin DOT com>
Subject: 'chop' and text mounts
Message-ID: <Pine.WNT.4.32.0103081659110.-294355@tiller2.ventritex.com>
X-X-Sender: jdtiller AT shell3 DOT ba DOT best DOT com
MIME-Version: 1.0

Hello, All, :)

I have a feeling this is an extremely trivial question, but it's
vexing to a relative newbie like me.  I'm just starting to learn Perl,
and I've run into a problem chop'ping lines that are CR/LF terminated.

Very simple example.  File 'a' has nothing but:

0000 0000 61 0D 0A                                           a..

(Hex dump produced using a non-Cygwin tool.)

My cwd is on a text-mode mount:

/c/emtplus/code/HS
$ mount
Device              Directory           Type         Flags
C:\cygwin\bin       /usr/bin            system       binmode
C:\cygwin\lib       /usr/lib            system       binmode
C:\cygwin           /                   system       binmode
a:                  /a                  user         binmode
c:                  /c                  user         textmode
d:                  /d                  user         textmode
(blah blah blah)

I would expect that when Perl reads a line, Cygwin would give it a \n
terminated line because I'm in text mode.  Then chop() would remove
that \n (if I understand how chop() is supposed to work!)

Unfortunately, reading from the simple 'a' file above gives me this:

$ perl -e 'open( A, "a" ); chop( $_ = <A> ); print;' | xxd
0000000: 610d                                     a.

Reading it from STDIN gets me:

$ perl -e 'chop( $_ = <STDIN> ); print;' < a | xxd
0000000: 610d                                     a.

I tried fiddling with "binmode" after reading perldoc, but to no joy:

$ perl -e 'open( A, "a" ); binmode( A, ":crlf" ); chop( $_ = <A> ); print;' | xxd
0000000: 610d                                     a.

I'm *sure* that tons of people have come up against this in the past.
BTW, a search of the online perldoc didn't turn up much.

I'm running on all the latest stuff (re-ran setup.exe a week or so
ago).  I realize I could do something like:

s/\015$//;

But I'd like to not have to.  Thanks for any help y'all can provide!

---Jason Tiller
jtiller AT sjm DOT com
Sonos


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


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