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

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@sjm.com
Sonos


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

