Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Carrige Return and Line Feed in Perl.

by dannyd (Sexton)
on Mar 01, 2011 at 20:57 UTC ( [id://890817]=note: print w/replies, xml ) Need Help??


in reply to Re: Carrige Return and Line Feed in Perl.
in thread Carrige Return and Line Feed in Perl.

All questions answered in 3 posts ^^ wow..didn't expect that!

I guess a lot of them were repetitions, but to my mind before the posts they were not...so its still a wow...

Thanks toolic, moritz and Eliya for all the information, some of this stuff has been plaguing me for a while now.

Note to self : Start chomping away, and search perldocs first before posting :)

  • Comment on Re^2: Carrige Return and Line Feed in Perl.

Replies are listed 'Best First'.
Re^3: Carrige Return and Line Feed in Perl.
by Marshall (Canon) on Mar 02, 2011 at 14:18 UTC
    Also a bit of history: Wiki CRLF history. This is extra info - some folks find it interesting.

    Many moons ago I worked with these ASR33 teletypes. In order to see one now, you'd have to go to a museum or watch an old black and white film. These things used paper tape which had lubricating oil embedded in the tape. On the keyboard, on the right, there were 3 keys arranged together: Carriage return (CR), Line Feed (LF) and rubout (NULL) (not just a single "return" or "enter" button). The paper tape was 8 bits wide, a NULL meant to punch holes in all 8 positions. The normal sequence to end a line was: CR, LF, Rubout.

    I'm not sure that I buy all of the explanation in the wiki article. The ASR33 was a very stupid thing and I think part of the reason was to just have a separate key for each mechanical action (eg separate CR from LF). This also allowed low resolution pictures of a sort to be printed by repeatedly printing over the same line (no LF). I saw many pictures printed like this so, the Wiki theory that LF was needed as time delay for the CR mechanics is doubtful - there was hardware flow control. The lubrication for the mechanical fingers came from the tape itself, so the periodic Rubout after every line served to keep all of the fingers well lubricated. A series of rubouts served to indicate the preamble and postamble to a tape. Nasty stuff as all the folks dealing with these oil soaked tapes wound up with grease stains in their shirt pockets! We viewed optical tape readers as a major technological advance! No more oil in the tape and therefore no more grease stains in the shirt pockets!

    On a more practical side of things, I exchange programs from my Windows box to Unix and vice-versa. Last month I wrote 2 Perl files on Unix with vi and one Perl file on Windows. Perl on either machine didn't care and the program ran on both machines (Perl doesn't care for its own program). I haven't had trouble with exchanging data files when Perl is doing the reading.

    I use TextPad (a shareware program) for my Windows program editor and it doesn't care either. The trouble happens when you are exchanging data with something like Windows NotePad which does care (it cannot deal with just LF as a "newline" character). However a simple Perl program that chomps and then re-writes the line with a "\n" seems to set things right (results in \r\n when run on Windows and just \n when run on Unix).

    So by and large, I figure that Perl did about as well as can be done with this mess.

    If you are say hashing to disk with a fixed record size in bytes, this is certainly a consideration, but I've written multi-platform programs that work fine. This is a detail that matters, but there are solutions. But for the most part, this is not important at all, except when the output file is going to be used by a non-Perl application that can't deal with different line endings.

      Marshall:

      FYI: I can corroborate the Wikipedia story that if you printed a character immediately after the CR that it appears as a smudge during the carriage return. It's a remarkably clever, but dumb device. I can still imagine the sound of our school's teletype.

      Boring story: When I was in High School, my friend Tim came up to me, and says "Hey, Marco! We have a computer at our school!" Needless to say, this was when having a computer at school would be a remarkable thing. Anyway, he leads me to Mr. Lamkin's math class, and shows me the teletype. It turns out that we didn't have a computer at school, but all the schools in the district were issued a teletype, acoustic MODEM and accounts on the timeshare (an HP-2000, if I recall correctly).

      There were no computer classes at our school, so when Mr. Lamkin saw that we were interested in it, he gave us accounts on the computer and said we could use it as much as we liked.

      We liked quite a lot! So we would often cut other classes to work on the computer in his math class, while he was teaching Trigonometry and Pre-calculus. As the teletype was a noisy beast, he got tired of hearing it during class. But rather than revoking our computer privileges, he got the school to move the teletype to an unused storage room, and gave us access to it there.

      A few other guys were interested, and soon afterwards, we had a gang of us teaching ourselves computer programming.

      One other fun fact: One of the guys in the group was my boss up until a few months ago.

      Ah, well, end of old-man reminiscences...

      ...roboticus

      When your only tool is a hammer, all problems look like your thumb.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://890817]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-25 08:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found