• 1 Post
  • 402 Comments
Joined 7 months ago
cake
Cake day: June 24th, 2025

help-circle



  • A bit of Perl code from the late 90s/early 2000s that worked something like this (working from memory, untested):

    my $hits = `grep $search_string $file`;
    my @lines = split /\n/, $hits;
    my @real_hits;
    for( my $i = 0; $i < scalar(@lines); $i++ ) {
        my $line = $lines[0];
        if( $line =~ /$search_string/ ) {
            push @real_hits, $line;
        }
    }
    

    Let me explain a bit about what this does. Instead of reading a file line-by-line and using Perl’s regex engine to match, it uses backticks to call out to the shell for grep. Those are split up by line. Then go through those lines (in a C-style for loop, not the perfectly good foreach version that Perl has had for a long time) and now we use a regex to match that line. You know, just in case shell grep didn’t do its one job.

    If anything, I’m probably making this code look better by declaring variables with my and following use strict standards.

    This was written by a guy who was the main programmer before I was hired. I was told he was a real piece of shit. He often had some checks in his code that, if not passed, threw messages to the client like “WE HAVE DETECTED YOUR HACKING AND LOGGED YOUR IP ADDRESS WE’RE GOING TO GET YOU”. Never met him personally, but his code is a pretty good example of why everyone came to hate Perl.















  • On a tangent, I appreciate this bit in Daniel Whiteson’s answer:

    “I’m not a fan of categorizing things as ‘science’ or ‘not science,’ because who knows what nerdy curiosity will lead to a discovery?”

    And also in Thomas Van Riet’s answer:

    “People say that without experiment we cannot call one theory better than another. That is plain wrong. There are many consistency checks, which are ridiculously hard to pass. Can you compute black hole entropy? String theorists were able to compute it in very idealized circumstances and reproduced Hawking’s famous formula for black hole entropy!”

    You’ll sometimes see flat earthers, creationists, etc. taking a textbook definition of the Scientific Method, claim that anything that doesn’t do that is “not science”, and therefore wrong. Except that’s not at all how it works. The important part is gathering data to support your claims. That data could be experimental, but it could also be observational.