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

Re: [MacPerl] Recognizing Unix Line Breaks



Thomas R. Kimpton wrote:

> How about:
> @lines = split(/(\012|\015|\015\012){1,1}/,$buf);  #if only \015?\012? would work
> 
> though the {1,1} may be unnecessary...

Make that:

	@lines = split(/\015\012|\012|\015/,$buf);

since the alternatives are always tried out from left to right, there's
no chance that the "\012" in "\015\012" would be forgotten.


** Note for people in a hurry: the rest of this post isn't too relevant.

Angus McIntyre wrote:

> Surely CRLF dates from the early electro-mechanical output devices (such as
> teleprinters) where one code was required to send the carriage back to the
> start position and a second one to force a linefeed. There must have been
> cases where it made sense to issue one without the other, so the two were
> kept separate.

Example of where it makes sense: a precentage status indicator, like in
PKZIP. Just use "CR" to go back to the left side of the page, and
overprint with the new value.
 
> CRLF makes sense when you think of physically controlling a device, but
> it's a poor choice as a logical separator. I suppose we should be grateful
> that it was Microsoft who stumbled into that particular Bad Design
> Decision; it could just as easily have been Apple. It's just a pity that
> Apple didn't go with the UNIX standard from the outset.

I always thought the choice in UNIX had something to do with
superstition: if they had to choose between 10 or 13, they preferred not
to use 13.

Anyway, think of a typewriter: when you use the carriage return handle,
the whole thing moves to the left side of the paper, AND also moves to
the next line. Therefore, Apple's choice makes more sense. A bit.


But I strongly agree with one of the earlier posters: computer programs
should accept *any one* of these in their input, and pick any of it's
liking for it's own output.

If only writers of Internet/CGI servers would make their programs work
like this...

-- 
		Bart Lateur
		Gent (Ghent, Gand),
		Belgium,
		Europe,
		3rd planet from the sun.


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