• Ejfsk (unregistered)

    Self modifying source code.. been there, done that, moved to more sane ways of thinking. Also frist.

  • Stuart (unregistered)

    Self modifying code is fine as a learning exercise. But for anybody to submit it as part of an operational piece of production code should be a sacking offence. No notice, no warning, just a simple "Get out. Now."

    Oy vey.

  • Perly (unregistered)

    The ->[] to access array elements should just be []. The foreach should be 0..$#lines because that gives you exactly what you want and is simpler. The self-modifying thing is just ridiculous, though.

  • Edd (unregistered)

    Not good enough for a wtf, should have modified the code from the same file for that.

  • dcsw (unregistered) in reply to Perly

    $lines is an arrayref, not an array, so the way the code is written is necessary. The only clear improvement is to change @{$lines} - 1 to $#{$lines}

  • Yazeran (unregistered)


    Ok, I may not be the best to comment on this as I do a lot of Perl coding, but evalling anything user based is just plain wrong and a sceurity hole. Sometimes you have to allow it though (and I have made software where it was possible to allow, but the default has always been to disallow it and the place where it could be enabled always included a huge warning about the issues with enabeling it). But doing regexps on something user-supplied and then evalling it afterwards, that's just like running amok with a hammer in a land mine storage depot....

  • Naomi (unregistered)

    ...drunk, blindfolded, in the snow, uphill both ways!

  • I'm not a robot (unregistered)
    Ok, I may not be the best to comment on this as I do a lot of Perl coding
    ... Implying that knowing what you're talking about is considered a bad thing around here?

    Actually, that explains a lot.

  • Lord Dampnut (unregistered)

    Now I have a bruise on my forehead from hitting the desk. Good start to the week.

  • s/perl/wtf/g (unregistered)

    This is a good one :)

    I normally have some 'I once did something similar ...' (even if I was just messing around or I was young and didn't know better), but self-modifying code in production? That is a quality WTF.

  • sizer99 (google)

    I have to applaud, because normally on these there's a 'well, that's not necessarily a wtf because if the moon is blue and you're being forced to use this Java framework then this is not a terrible hack'. ButI can't think of any situation outside of assembly language on terribly constrained systems (been there, done it) where self-modifying the code (with regexps, even) could be seen as better in any way than just adding a command line parameter or function parameter.

  • sizer99 (google) in reply to Yazeran

    He's doing it on his own single specific script, not arbitrary scripts, so it's not that giant a security hole in this one case.

    But since they're both his own scripts, there's also no excuse for not just doing it properly.

  • Decius (unregistered)

    Works just fine until Bobby Tables gets his CV scanned.

  • Yazeran (unregistered) in reply to sizer99

    I know he is doing it on his own script, but he (or the boor guy taking over) has to remember that he can not just add lines to the script without having to consider what those regexex will do the script afterwards. And speaking from experience, going back to something you did a few yers ago to add new functionality or similar can take a while to get in to what the code did in the first place, and then remembering what it will do after a regex replace will likely not be first on the list of things you remember (especially since it mentions that he never wrote any meaningful comments).

  • Ulysses (unregistered)

    So is the first asterisk meant to be a regex pun, or did someone forget to write the intended footnote?

  • (nodebb)

    He had the inkling to write DRY code, but went about it in the worst possible way.

  • I dunno LOL ¯\(°_o)/¯ (unregistered) in reply to Ulysses

    I have a feeling that the articles are formatted using (ugh) Markdown, and the asterisk was supposed to be un-bold, but the initial bold character was mis-typed as whatever causes italics. At least there was an extra un-italics in there.

    Or maybe Remy ran the article through another Dennis script.

  • Anon (unregistered)

    I submitted this. And I'm sad to report that this is probably the least of his transgressions - I've got plenty more content I'm gonna submit. Stay tuned for regex crimes against humanity

  • Anon (unregistered) in reply to Perly

    The arrows are because it's a reference rather than a list

  • Anon (unregistered) in reply to sizer99

    OP here. Correction, he is doing this on 152 separate scripts. Biggest commit of my life

  • Ulysses (unregistered) in reply to I dunno LOL ¯\(°_o)/¯

    Ha I'm sure it's the former. Goes to show these guys don't proofread their shizzle.

  • Anon (unregistered) in reply to Ulysses

    If I'm honest mate I don't think he could even read. He had those massive binocular glasses. Absolute Dilbert

  • Yazeran (unregistered) in reply to Anon

    Gah, so not only do you have to consider what THIS script does, but also think about what other script may or may not do to it later on with regexes and what the script could then do after a failed 'conversion'....

    Truely a monumental regex WTF!

    I mean even thinking about doing a regex replace on a program/script gives me shivers, but doing it on 100+ scripts... whimper

  • Anon (unregistered) in reply to Yazeran

    Honestly the "framework" as it was so dubbed was essentially one big Rube Goldberg machine that "might" spit out some XML at the end

  • Anonym00se. (unregistered)

    Nitpick... but

        next if index($lines->[$n], 'RT::Spider::Deepweb::Controller::Factory->make(') == -1;

    Skips lines if they don't contain... not if they contain. :)

  • Anon (unregistered) in reply to Anonym00se.

    He LOVED doing that. Every condition was backwards. He abused the 'unless' keyword. Spent many hours trying to unburst my brain and write them sensibly.

    He abused ternaries too. I once found one 5 layers deep. I don't know how I'm still alive.

Leave a comment on “Perls Can Change”

Log In or post as a guest

Replying to comment #:

« Return to Article