This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Perl, text files, & \r


Perl is the Pathologically Eclectic Rubbish Lister after all (but don't tell
anyone I said that).  The vast majority of scripts are intended to process
text which makes it very handy that the line ending variations can be
abstracted.

The poorly thought out part was MSDOS bringing forward the CP/M text file
format with "\0x0D\0x0A" to end lines and "\0x1A" to terminate the file.
Since then, every MSDOS C I/O library has had to convert "\0x0D\0x0A" to
"\n" for text files to make line endings look the same in MSDOS or UNIX.

If you want absolute control of your file I/O, you can and should call
binmode().  This is not accommodating anything, it is complying with the
documented behavior of the language.

The Cygwin environment _does_ attempt to help programs compiled in it deal
gracefully with MSDOS line endings.  That is what the '-b' and '-t' switches
are for in the mount command.  If you mount a directory tree with the '-b'
option, you get exactly the behavior you want.  With the '-t' option, you
get the behavior you seem to be so steamed about, but that can be overridden
with binmode() as I stated above.

What does Microsoft have to do with the Perl build in Cygwin?  If you
consider Microsoft's behavior parental, I'm glad I'm not in that family.
--
Mac :})
** I normally forward private questions to the appropriate mail list. **
Give a hobbit a fish and he eats fish for a day.
Give a hobbit a ring and he eats fish for an age.
----- Original Message -----
From: "Christopher Rath" <christopher@rath.ca>
To: "Cygwin Maillist" <cygwin@cygwin.com>
Cc: "Michael A. Chase" <mchase@ix.netcom.com>; <gp@familiehaase.de>
Sent: Sunday, July 08, 2001 15:08
Subject: RE: Perl, text files, & \r


> <flame>
> I personally resent the fact that perl tries to hide from me the fact that
> MS-DOS text files use <CR><LF> and not just <LF> as their end of line
> sequence.  The choice to translate and obscure reality as a default is
> something I consider rather poorly thought out.  A file is just a file;
it's
> a collection of bits.   The fact that it contains structure should not be
> imposed by the interpreter; rather it should be handled by the programmer.
>
> The cygwin tools themselves (e.g., makeindex) don't attempt to deal with
the
> <CR><LF> issue, so why does perl?  The default behaviour should be NO
> translation (i.e., binmode on).  If I want the computer to do something
for
> me then I'll make the request.  Perl's present behaviour is exactly the
type
> of parental attitude Microsoft so commonly displays and it is rather
> unbecoming when it appears in perl.
>
> My perl script deals properly with the content of the files it encounters;
> however, when I wrote it I never accommodated perl's file I/O behaving in
> such a fascist manner.
> </flame>



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]