Chris Wagner wrote:
> At 03:56 AM 6/24/05 -0700, $Bill Luebkert wrote:
>
> I think ur missing the point. Let me try a different way. Within the black
> box fuzzy cloud that is perl, there is a placeholder for the new line
> sequence which is "\n". Like a quantum particle that has no definate
> position or velocity until u try to measure it. When we "do something" with
> \n it "turns into" some bytes that make sense for the current context. The
> default thing for it to turn into is ^J.
None of that is true. There is a concept of a record separator that can
be used to alter what Perl's idea of a line is, the that separator is by
default a newline (\n) on input and nothing on output (which means it
uses whatever you print [usually \n] as the newline).
What Perl calls a newline corresponds to the LF character or ^J.
The newline is not a placeholder and Perl doesn't turn it into anything.
> It's so common that we just think
> of them as being synonymous. But it can turn into ^M^J or even just ^M.
> Beyond that we're arguing over C code and perl source. I don't care that
> much. If we want to talk strict ASCII, there is by definition no such thing
> as a newline character.
But there is common terminology and in that arena, newline and \n and ^J are
all the same. Perl does no conversion of \n to anything.
> To make a "new line" we have to reset the cursor
> position to 0 (carriage return ^M) and increment the line count by 1 (line
> feed ^J). You can say that this is just because of the terminal, well ur
> right. There's no such thing as a "line" or a "new line" except in the
> context of a terminal device. Internally there's nothing but bitstreams.
> It's just a space saving (laziness) convention to omit one of the bytes in
> the new line sequence. It actually makes a little sense when ur 40 MB
> harddrive costs $500 and you have a 110 baud teletype. The fallout of that
> is we now have an implicit construct for making "new lines" that not
> everyone agrees on.
I disagree with your assumption that Perl has anything to do with
converting LF to CRLF. Perl does not do it, the Windoze C library
does it when you use text mode IO. If you use text mode IO on UNIX,
it doesn't do it - the Perl code is the same in both cases, it's the
underlying runtime library that's doing the conversion. If you want
to call that a virtual newline, so be it, but it's still just a
plain old linefeed character (that's also got an alias name as the
newline character [due to popular usage]). I really don't care
whether you call it a linefeed or a newline character - it's still
the same character and we're only talking name here.
Here's the conversion chart on what happens to your \n when you print
it (Perl does not do this transform [not sure about Mac though - it
may be kludged], the underlying runtime library does) :
| Unix | DOS | Mac |
---------------------------
\n | LF | LF | CR |
\r | CR | CR | LF |
\n * | LF | CRLF | CR |
\r * | CR | CR | LF |
---------------------------
* text-mode STDIO
| z/OS | OS/400 |
----------------------
\n | LF | LF |
\r | CR | CR |
\n * | LF | LF |
\r * | CR | CR |
----------------------
* text-mode STDIO
>>Proof - Perl script:
>>
>>$_ = "1234567890\n";
>>dumpit ($_); # dumpit does a hex/character dump of a vrbl to STDOUT
>
>
> Because in that context \n degenerates into ^J. >:)
It *ALWAYS* generates a ^J - *ALWAYS*. It may not look that way
when it gets to a file, but the string in memory does.
>>But if you really wanted a DOSish file on UNIX, you would be correct
>>in doing what you are doing - just can't think of a reason to do it. :)
>
>
> Some programs (especially notepad) can't handle anything but CRLF.
Nobody in their right mind would ever use a program as rotten as notepad
for anything unless that had nothing else to use. ;) At least use Wordpad.
> Let's not get into the stupidity of the MAC line ending. That's kinda
> like asking Unix builders why they chose to use / instead of \ as a
> path separator - one of the dumbest design moves in history.
Just ask yourself which is easier to type and which is always in the
same place on all keyboards and which one moves around from keyboard
to keyboard.
> Heh, we're talking ~1979 here. There was nothing but random fog back then.
Not for me there wasn't - UNIX was already flourishing in the early 70s
and DOS was nothing more than a wet dream showing up 10 years later. I
was working on minis back then and didn't get into UNIX until a few years
later in the late 70s.
> I think we've had enough nerdish computer scientistish speak for one day.
Doesn't mean you can invent new words. :)
--
,-/- __ _ _ $Bill Luebkert Mailto:[EMAIL PROTECTED]
(_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED]
/ ) /--< o // // Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_ http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs