Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Is this OK?

by jwkrahn (Abbot)
on Apr 09, 2022 at 22:56 UTC ( [id://11142880]=monkdiscuss: print w/replies, xml ) Need Help??

Is it OK to post some Perl code I found on the web and critique/make fun of it, or should I just post it on https://thedailywtf.com/ ?

Replies are listed 'Best First'.
Re: Is this OK?
by choroba (Cardinal) on Apr 09, 2022 at 23:09 UTC
    I think it's OK. As a Meditation, almost anything goes. When I encountered really weird code at work, I tried not only to understand it, but also to reproduce the same behaviour under strict and warnings, making it a challenge for me, see Can you use string as a HASH ref while "strict refs" in use?. So maybe give it a second thought and try to make the post more educative or challenging instead of just critique or fun...

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

      OK, thanks.

Re: Is this OK?
by LanX (Saint) on Apr 10, 2022 at 10:12 UTC
    I think as long as you make fun of the code, instead of ridiculizing an amateur author it's ok.

    So maybe try to anonymize it to a certain degree. Not excessively so, but avoid names.

    After all it's in the web and could be used as a blueprint by others, so it's not above criticism.

    Of course you could be more explicit, if the author was using bad code for evangalizing or profit.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

Re: Is this OK?
by eyepopslikeamosquito (Archbishop) on Apr 10, 2022 at 11:31 UTC

      My evil plan failed when the perpetrator was too lazy to respond.

      While i'm not the original perpetrator, i might have something. If you really need some horrifying code to be happy, i happy to look into my own source code archives this evening and have a go at trying to dig something up from one of my very early perl projects(*). Can't promise anything, haven't touched those repos in nearly 18 years, but they should still be readable.

      (*) In a movie, this would be the time to [Cut to black&white flashback with a swirly transition]
      perl -e 'use Crypt::Digest::SHA256 qw[sha256_hex]; print substr(sha256_hex("the Answer To Life, The Universe And Everything"), 6, 2), "\n";'

        > If you really need some horrifying code to be happy...

        Ha ha, it only makes me happy when I understand the root cause of how it happened in the first place. When I see truly horrifying code in production at work, I'm not interested in ridiculing the individual responsible, I feel profoundly curious as to how on Earth such code made it into production in the first place ... and feel an irresistible urge to uncover the root cause to make sure it doesn't happen again.

        One common cause of ridiculously bad code making it into production I've seen is when the non-technical manager (who never looks at the code) rates an individual's performance based on KPIs, such as productivity. Team-based KPIs produce higher quality and more maintainable code in my experience. These topics are touched upon in:

Re: Is this OK?
by cavac (Parson) on Apr 12, 2022 at 14:33 UTC

    I'd say there are some things to consider:

    • Make sure you have the legal right to post the code (License, Fair use, etc).
    • Make fun of the code, not the author.
    • Don't just post it for the lolz. Make it in the form of "instead, they should have done this and that instead"

    perl -e 'use Crypt::Digest::SHA256 qw[sha256_hex]; print substr(sha256_hex("the Answer To Life, The Universe And Everything"), 6, 2), "\n";'

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-19 16:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found