Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      June 2, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      June 2, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      June 2, 2025

      How To Prevent WordPress SQL Injection Attacks

      June 2, 2025

      How Red Hat just quietly, radically transformed enterprise server Linux

      June 2, 2025

      OpenAI wants ChatGPT to be your ‘super assistant’ – what that means

      June 2, 2025

      The best Linux VPNs of 2025: Expert tested and reviewed

      June 2, 2025

      One of my favorite gaming PCs is 60% off right now

      June 2, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      `document.currentScript` is more useful than I thought.

      June 2, 2025
      Recent

      `document.currentScript` is more useful than I thought.

      June 2, 2025

      Adobe Sensei and GenAI in Practice for Enterprise CMS

      June 2, 2025

      Over The Air Updates for React Native Apps

      June 2, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      You can now open ChatGPT on Windows 11 with Win+C (if you change the Settings)

      June 2, 2025
      Recent

      You can now open ChatGPT on Windows 11 with Win+C (if you change the Settings)

      June 2, 2025

      Microsoft says Copilot can use location to change Outlook’s UI on Android

      June 2, 2025

      TempoMail — Command Line Temporary Email in Linux

      June 2, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»CodeSOD: Irritants Make Perls

    CodeSOD: Irritants Make Perls

    January 13, 2025

    Grün works for a contracting company. It’s always been a small shop, but a recent glut of contracts meant that they needed to staff up. Lars, the boss, wanted more staff, but didn’t want to increase the amount paid in salaries any more than absolutely necessary, so he found a “clever” solution. He hired college students, part time, and then threw them in the deep end of Perl code, a language some of them had heard of, but none of them had used.

    It didn’t go great.

    # note that $req is immutable (no method apart from constructor sets a value for its members)
    sub release {
       my $req = shift;
      
       my $body = 'operation:' . ' ';
    
       if (uc($req->op()) eq 'RELEASE') {
            $body .= 'release' . "n";
            # do more stuff to body
            ...
       }
       else {
           $body = 'operation: request' . "n";
       }
    
       if (uc($req->op()) ne 'RELEASE') {
               register_error('unable to send release mail');    
       }
       
       # and so on
       ...
    }
    

    This method checks a $req parameter. Notably, it’s not being passed as a prototype parameter, e.g. as part of the signature– sub release($req)– but accessed by shifting out of @_, the special variable which holds all the parameters. This is the kind of move that gives Perl it’s reputation for being write only, and it’s also a sign that they were cribbing off the Perl documentation as they write. For whatever reason, using shift seems to be the first way Perl documentation teaches people to write subroutines.

    This whole thing is doing string concatenation on a $body variable, presumably an email body. I’d normally have unkind words here, but this is Perl- giant piles of string concatenation is just basically par for the course.

    The “fun” part in this, of course, is the if statements. If the $req is to “RELEASE”, we append one thing to the body, if it’s not, we append a different thing. But if it’s not, we also register_error. Why couldn’t that be in the else block? Likely because the poor developers didn’t have a good understanding of the code, and the requirements kept changing. But it’s a little head scratcher, especially when we look at the one place this function is called:

    if (uc($req->op()) eq 'RELEASE') {
         return release($req);
    }
    

    Now, on one hand, having the function check for its error condition and avoiding triggering the error condition at the call site is good defensive programming. But on the other, this all sorta smacks of a developer not fully understanding the problem and spamming checks in there to try and prevent a bug from appearing.

    But the real fun one is this snippet, which seems like another case of not really understanding what’s happening:

    if(($ok1==1 and $ok3==1)or($ok1==1 and $ok3==1))
    {
        print p("Master changed!");
    }
    

    We just check the same condition twice.

    Now, of course, it’s not the developers’ fault that they didn’t have a good picture of what they should have been doing. Lars was trying to save money by hiring the inexperienced, and as usually happens, the entire thing cost him more money, because Grün and the rest of the team needed to go back over the code and rewrite it.

    The upshot, for our college students, is that this was a good resume builder. They’ve all since moved on to bigger companies with better paychecks and actual mentoring programs that will develop their skills.

    [Advertisement]
    BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!

    Source: Read More 

    Hostinger
    Facebook Twitter Reddit Email Copy Link
    Previous Article10 Top Free & Premium WordPress Plugins for 2025
    Next Article Il podcast di Marco’s Box – Puntata 201 (con video!)

    Related Posts

    News & Updates

    How Red Hat just quietly, radically transformed enterprise server Linux

    June 2, 2025
    News & Updates

    OpenAI wants ChatGPT to be your ‘super assistant’ – what that means

    June 2, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    Plex has to cave and raise its prices after a decade — act now and lock in for life before it happens

    News & Updates

    Dataset Reset Policy Optimization (DR-PO): A Machine Learning Algorithm that Exploits a Generative Model’s Ability to Reset from Offline Data to Enhance RLHF from Preference-based Feedback

    Development

    From Fiction to Fact: 7 Hacking Movies That Get Cybersecurity Right

    Development

    Dragon Quest 12 is still in development, says creator Yuji Horii, with new information coming soon

    News & Updates
    GetResponse

    Highlights

    Databases

    Performing a minor version upgrade for Amazon RDS Custom for SQL Server CEV with Multi-AZ

    August 29, 2024

    Amazon Relational Database Service (Amazon RDS) Custom is a managed database service that provides administrative…

    Biden signs Executive Order for building out AI infrastructure

    January 14, 2025

    Early Prime Day deals on the best PC upgrade parts are already tempting with huge discounts — here’s what I’d buy

    June 26, 2024

    Using Multichannel and Speaker Diarization

    December 7, 2024
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.