Dreamlogic



  • This morning I was woken up by some particularly loud birds directing their squawking towards my open window.  I frequently sleep with pillows covering my ears for such a thing, but they were not present to protect me this time.  Every time I reached out for a pillow, the birds squawked more.  Ok, now, in Perl, "\n" interpolates into the line ending of the platform it's running on; e.g., "\n" is actually "\r\n" in Windows.  Somehow, I got it into my head that on my platform,"\n" was being interpolated into "\a\n".  That is, the bell character would be prepended to each newline.  In my case, the bell was the bird; such that every time I moved, the bird would squawk.  Fortunately, I was able to escape this delirium after observing that sometimes the bird would squawk even when I did not move.



  •  Quiet, fool, lest you give Larry Wall more ideas for Perl 6!



  • @bstorer said:

    Quiet, fool, lest you give Larry Wall more ideas for Perl 6!

    One word: Parrot.



  • @morbiuswilters said:

    @bstorer said:

    Quiet, fool, lest you give Larry Wall more ideas for Perl 6!

    One word: Parrot.

    Well, I meant ideas for things that will actually exist one day, but point taken.



  • lol, when I read the OP I actually thought it was one of those spam bots that take random sentances found on the web to create bullshit content. The shift from birds to talking about new lines wasn't exactly smooth ;)

    But I know the feeling of half sleep half dream state logic. It's also this state in which I convince myself that I should just shut off my alarm clock and close my eyes for just 5 seconds before coming out of bed. 



  • @Xyro said:

    Ok, now, in Perl, "\n" interpolates into the line ending of the platform it's running on; e.g., "\n" is actually "\r\n" in Windows.

    Not quite, "\n" is still one character; the I/O layer does what you describe when writing into text files.



  •  @Spectre said:

    @Xyro said:
    Ok, now, in Perl, "\n" interpolates into the line ending of the platform it's running on; e.g., "\n" is actually "\r\n" in Windows.

    Not quite, "\n" is still one character; the I/O layer does what you describe when writing into text files.

    Freely admitting that I'm a complete Perl n00b, I've always wondered if it works the other way, too. Meaning, if I use \n in a regex, will it actually match \r\n in Windows and \r on a mac? And if yes, if I wanted to match plain-\n in Windows for some arcane reason, what would I do then?

    Or asked in another way, would the IO layer convert \r\n back to \n when reading in data (in windows) and what would it do with plain-\n then?



  • @Spectre said:

    Not quite, "\n" is still one character; the I/O layer does what you describe when writing into text files.

    Aww, I was close enough, but that is a good point. If you have a string literal, like my $dos_text = "dos\015\012text";, that will be seen as two characters (of course), and doing a regex of "two\nlines" =~ /(\w*)(\W*)(\w*)/ will always show length($2) == 1 regardless of platform. (For the un-PCRE'd, \w is a word character, \W is a non-word character.)
    @PSWorx said:
    Or asked in another way, would the IO layer convert \r\n back to \n when reading in data (in windows) and what would it do with plain-\n then?

    Yes, and plain-\n gets treated as a newline, too, without fuss. However, funny and unfortunate things can happen if you read DOS newlines in a Unix environment. The \n gets chomped, but you still have a \r that does bad things to printed output. :-\ In that case, you either have to change the input record separator with $/, fix the input with a regex (s/\r$//;), or use one of the more sophisticated IO:: modules to take care of it.

    In general, rather than a literal linefeed character, Perl's \n usually just signifies an end-of-line marker, be that what it may. You can apply a finer set of control on the text if you need it. It's also not untypical to see \015\012 in network protocol code to make sure CRLF is sent out. And if you need the real bytes, you can use [url="http://perldoc.perl.org/functions/binmode.html"]binmode[/url].



  • I always thought that I was mentally ill because I dream about code. Now I know I'm not the only one.



  • [quote user="Renan "C#" Sousa"]I always thought that I was mentally ill because I dream about code. Now I know I'm not the only one.[/quote]Don't discount that.  Many (maybe most?) coders do, so you still might be mentally ill like the rest of us.  Actually, forget about dreaming about code.  Have you ever dreamed in code?  Every so often, I have indescribably intense dreams which are expressed exclusively in terms of algorithms, data structures, and data flows, usually in Perl. (For whatever reason, Perl is my brain's dreamlanguage of choice.)  I usually wake up from these dreams frustrated and unrested, as I can't mentally keep up with all the computations. Normal dreams are always characterized as at least visual, but my code dreams are neither visual nor tactile nor any other sense. All is distilled away but the profound concepts of programming...



  •  My dreams tend to be FPS-y.



  • @Xyro said:

    For whatever reason, Perl is my brain's dreamlanguage of choice.
    Congratulations: your brain is fucking retarded.



  • @Xyro said:

    (...)Actually, forget about dreaming about code.  Have you ever dreamed in code?  Every so often, I have indescribably intense dreams which are expressed exclusively in terms of algorithms, data structures, and data flows, usually in Perl. (For whatever reason, Perl is my brain's dreamlanguage of choice.)  I usually wake up from these dreams frustrated and unrested, as I can't mentally keep up with all the computations. Normal dreams are always characterized as at least visual, but my code dreams are neither visual nor tactile nor any other sense. All is distilled away but the profound concepts of programming...

    Yes. And it's just like that. I don't know which language specifically I dream about, all I can feel are the instructions being executed in an orderly manner in many simultaneous threads. Sometimes I try to understand what they are doing, but only in a minority of them I can see what the program is trying to accomplish.



  • Holy crap!

    What a bunch of freaks.

    All of you dreaming about code, STOP IT. Think about a career change, or watch more porn before going to bed.

    All of you dreaming IN CODE, go to a shrink and start getting medication ASAP.



  • @fatdog said:

    Holy crap!

    What a bunch of freaks.

    All of you dreaming about code, STOP IT. Think about a career change, or watch more porn before going to bed.

    All of you dreaming IN CODE, go to a shrink and start getting medication ASAP.

    You're just jealous because you are too poor to dream in code.  The only thing you're allowed to dream of is Chavez's naked, rippling, heroic stomach torso.



  • @morbiuswilters said:

    You're just jealous because you are too poor to dream in code.  The only thing you're allowed to dream of is Chavez's naked, rippling, heroic stomach torso... with all the guts spilling out after being opened up with a rusty knife.

    Oh shit!, the Dreampolice National Security Squad might catch me illegaly dreaming.

    The current official bribe fare for illegal dreaming is $100 or 8 liters* of skimmed milk.

     

    * 8 liters = 2.11337642 US gallons


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.