[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] When is \r really \n in MacPerl!?



On 12 Feb 98 at 9:26, Mark F. Murphy wrote:

> Here's the output for Perl for Win32 Build 110 (script uses either
> Unix or DOS line endings):
>
> Ord \r: 13
> Ord \n: 10

*I* happen to think that for the moment we should ignore the line
endings in the script file. I agree with you (and many others) that
it would be good if MacPerl accepted LF, CR or LFCR (and probably
CRLF) as line end characters *IN* *SCRIPTS*, but I agree with
Matthias that that's really a perl core issue, not just a MacPerl
one. It's fairly easy to do the convertion anyway.

The DOS issue is interesting. I assume that the DOS implementation
has chosen to use \n as 10, and then presumably translate 10 to
local line ending character (CRLF or whatever) on output to text
files. Presumably using binmode to allow files to be declared
non-text and to cancel the translation.

One interesting catch is that you will then never be able to output
a 'bare' LF (=10) to a DOS text file (which you might concevably want
to do), since it will always become CRLF.

If the Mac used the same approach, \n (10 internally) would be
converted in Mac text text files to 13, and \r (13 internally) could
be output either as 13 or 10. Neither is ideal. The former would
give no way to output a 10 to a text file, the latter would lead to
\r appearing in text files as 10, line-feed!

It's significant problem. Essentially the C/Perl text file model
only holds for Unix, where line end is represented by a single
character, and there is no distinction between text and binary files.
Even if MacPerl changed the already established convention (breaking
lots of scripts), a significant number of imported Perl files would
still not work, because Unix perl programmers don't call binmode on
non-text files, so you would be no further forward.

My last word. I'm not going to say anything more on this in public
again. Ever. Until the next time...

Jon.
--
Jon Warbrick, Computer Systems Manager,                jw35@cus.cam.ac.uk
St John's College, Cambridge, CB2 1TP, UK.             +44 (0)1223 338751
(also webmaster, computer-support and part-time postmaster@joh.cam.ac.uk)

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch