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
[EMAIL PROTECTED]
Sonos


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

Reply via email to