• Forumtroll (unregistered)

    Perl Poetry Contest, anyone?

  • just me (unregistered) in reply to Pyrexkidd
    Pyrexkidd:
    Allow me to say this: perl is an idiomatic language; if you don't know the idioms, then understanding the language becomes more difficult.
    from your link:
    WordNet Search:
    idiom: an expression whose meanings cannot be inferred from the meanings of the words that make it up.
    says it all...
  • Plaga Rizer (unregistered) in reply to hoodaticus
    hoodaticus:
    Shondoit:
    I actually used a similar thing in QBasic, back in the days.

    Granted I was learning myself programming and as I recall there wasn't proper date manipulation in QB. Either that, or I hadn't learned it yet.

    Of course, it was a home brew program, used to log the login and logout time.

    Ah, the good ol' days.

    For every bad memory you just gave me of QBasic, I shall kill you.
    Hey, I liked the gorilla game!

  • Bobbo (unregistered)
    Kenneth Williams:
    Infamy! Infamy! They've all got it in for me!
  • really? (unregistered) in reply to wtf
    wtf:
    The Article:
    Sure, it's pretty easy to reference the DateTime module...
    "Reference" is a verb, not a noun. When are you people going to get you're language strait.

    I really hope that's a joke.

    When are you going to get your language straight? ("your" "straight" "?")

  • lol (unregistered) in reply to ObiWayneKenobi

    Tu é que me deixas violentamente doente com as tuas quiquices e sintaxe.

  • SteveS (unregistered)

    The best practice way to do this in modern perl is this:

    use DateTime;
    

    my $today = DateTime->today( time_zone => 'local' );

    then call methods on the DateTime object e.g.

    print $today->year, $today->month, $today->day, "\n";

    Not so scary huh?

  • Michael (unregistered)

    TRWTF is that this code is a classic tmpfile security vulnerability. It uses a well-known filename in /tmp. http://rute.2038bug.com/node47.html.gz#SECTION004714000000000000000

  • Anon (unregistered) in reply to Jack

    Why bash PHP?

    I've written nice clean sites using Zend Framework and MySQL - everything done OO-style, no functions longer than about 10 lines, proper commenting everywhere - and then scaled them to millions of users per month (I'm not kidding, I've worked on some very high traffic sites, and you may have heard of at least some of them).

    The people who took over from me only needed a few minutes of explanation on how things were set up - and then away they went. I've only had a few quick queries since.

    Yes, I've seen some pretty bad PHP code, but nothing like the lousy examples of Perl (or C for that matter) that I've come across.

  • (cs) in reply to H.P. Lovecraft

    Verbing nouns is productive in English, so there really is nothing wrong with 'referencing'.

  • (cs)

    This is just a fairly extreme case of a very common antipattern that I see all the time, especially in Perl code (probably because Perl is used a lot as a scripting language by relatively inexperienced programmers).

    The antipattern is that output of commands goes to files and input comes from files. No concepts of capturing output directly into memory, reading it from memory, or pipes. Commands operate on files, period.

    Underlying this is a more general antipattern, which might be called large-scale assembly programming. In this programming style, everything that happens happens on variables, and the only complex data type that is known is the array. There are lots of sequences of for loops, each reading out an array and filling in a new array to be used by the next loop. Applied to files, this mode of thinking gives you sequences of steps, each reading a (temporary) input file and producing a (temporary) output file.

    I think this is just an illustration of how programming concepts don't enter people's minds all at once. If it's a WTF at all, it's a WTF about teaching programming by starting out with C or BASIC.

  • My Name (unregistered) in reply to really?
    really?:
    wtf:
    The Article:
    Sure, it's pretty easy to reference the DateTime module...
    "Reference" is a verb, not a noun. When are you people going to get you're language strait.

    I really hope that's a joke.

    When are you going to get your language straight? ("your" "straight" "?")

    You, Sir, have been trolled.

    The wrong usage of "your", "you're" and similar in a post that is correcting other people's language is a bright flashing sign with the words "I am a troll." on this page.

  • (cs) in reply to My Name
    My Name:
    really?:
    wtf:
    The Article:
    Sure, it's pretty easy to reference the DateTime module...
    "Reference" is a verb, not a noun. When are you people going to get you're language strait.

    I really hope that's a joke.

    When are you going to get your language straight? ("your" "straight" "?")

    You, Sir, have been trolled.

    The wrong usage of "your", "you're" and similar in a post that is correcting other people's language is a bright flashing sign with the words "I am a troll." on this page.

    Also note that "reference" is more often a noun, not a verb. Although I verb that noun a lot.

  • (cs)

    We, as developers, need to make code more funnery to read

    while (<COOKING>) { chop; @soup = split(/pea/,$_); }

  • Danny Milosavljevic (unregistered) in reply to Anonymous

    I think the obvious point was that any language you don't know and whose goals you don't even know looks "bad" to you. It's like reading Russian when you can't speak the language or read the glyphs.

    That said, there's (usually) a good reason why things are how they are in a language.

    That program you criticise was written in the most well-known functional programming language in the world, emphasis on "functional". A functional is an abstraction of "function", like "function" is an abstraction of "relation". So of course it will take jumping through some hoops to achieve stuff that is wasn't designed for. But in return it can do things in a simple way you probably thought were impossible to do on a computer (i.e. handle infinitely long lists - and I don't mean that figuratively, but literally infinitely long).

    As for the perl example, some people should think about the pronouns "it", "this", "that", ... in human language. Perl was written by a linguist to be similar to how humans understand "their" language (genetic language seed).

  • Tomalak Geret'kal (unregistered) in reply to wtf

    I hope this is a trollpost. Firstly, "reference" was used as a verb. Secondly, it can be either. Thirdly, you misspelled "straight" and wrote "your" wrong.

  • WhatsWrongWithPHP (unregistered) in reply to EatenByAGrue

    So your saying because it's easy to write code that kinda works it's a bad language?

    Sounds like a good language to me.

  • (cs) in reply to Kiss me I'm Polish
    Kiss me I'm Polish:
    Can't blame the guy. He's probably not a programmer, and all he needed was a quick script. Or maybe he hadn't used Perl in a long time, and didn't find it necessary to relearn the language. It's somewhat useless to read a 450 page book about a programming language, when you need only a 5 lines script. Especially an ugly language. Of course he could have thought of something slightly easier, and somewhat less inspired by Rube Goldberg. And even maybe he could have pondered the possibility of a date handling set of routines built into the language.

    man perlfunc search for time

    HTH. HAND.

  • (cs) in reply to davee123
    davee123:
    ...

    A better, pure-Perl way to do it is more like:

        @lt = localtime;
        $today = sprintf("%04d%02d%02d,$lt[5]+1900,$lt[4]+1,$lt[3]");

    And better still is to just break down and use the Date::Time library.

    ...

    While it's not exactly pure perl, this only uses CORE libraries:

        use POSIX;
        $today = &strftime("%Y%m%d", localtime);

    That incidentally follows the same time format definitions that the date command uses (which come from the POSIX C libraries, hence the name of the module.) It's also faster than shelling to unix/dos by a huge margin, as it's not doing a fork-exec-exec. (Even in the original version, perl runs sh to run date. And it doesn't specify an absolute path for either.)

    Btw, I think you mean the DateTime module - I can't find a Date::Time module. DateTime is great when you need it, but really overkill most of the time. (If I were implementing a calendar, I'd absolutely use something like DateTime. If I'm just storing and reporting a few dates, no way.)

  • Frank (unregistered) in reply to Kiss me I'm Polish

    Perl is NOT ugly, it is beautiful.

  • Ptorq (unregistered)

    On the plus side:

    • Writing it was probably quicker than installing the DateTime module
    • Unlike DateTime, /bin/date is almost certain to exist on any reasonable impersonation of Unix
    • One of the mantras of Perl is TIMTOWTDI, and this particular WTDI is at least easy to understand/maintain

    If you're going to be playing around a lot with dates and dealing with sometimes programmatically tricky concepts like "two weeks ago" and "next Friday", DateTime rocks. If you just need to know what day of the month it is, this is a working (if not ideal) solution.

Leave a comment on “Classic WTF: A Date of Infamy”

Log In or post as a guest

Replying to comment #:

« Return to Article