Andy Lester: November 2007 Archives

Yesterday I noticed in my Apache access log a lot of 404s that looked like this:

aaa.xx.65.186 - - [25/Jul/2007:05:55:05 -0500] "GET HTTP/1.1" 404 305 "" "legitimate-looking agent"

Not only am I not hosting banner ads, the GET request is invalid. It should be GET /banner/digits..., without the scheme and hostname part of it. I wondered how many I had of these, and how many hits I was getting. A Perl one-liner to the rescue!

perl -MData::Dumper -nae'++$n{$F[0]} if /GET http/; \
    END{print Dumper\%n}' access.log

$VAR1 = {
          'aaa.xx.65.186' => 132, # Real IPs obscured
          'bb.yyy.7.60' => 48,
          'ccc.zzz.46.147' => 111,
          'dd.qq.71.82' => 33

So it looked like I was getting hit by a couple of 0wnz0red boxes with some sort of virus on them. I added them to my iptables DROP list and was done with it.

80% programmers

| | Comments (3)

Ben Collins-Susmann writes about the 80/20 split of programmers and how the 20% of programmers who are "alpha programmers" have to account for the 80% who are not, and how they use their tools.

Although the post talks about Subversion and distributed VCSes, the lessons hold for those who use Perl, too. How many programmers have we worked with who don't know about CPAN, or are afraid to use code from CPAN? How about programmers who don't understand the internals workings of "standard" Perl objects (i.e. blessed hashes), who don't realize that a {} is an anonymous hash constructor, not a "class" or "object" constructor? Or who are afraid to use the map and grep constructs?

On the flip side, you don't want to dumb down your code to the lowest common denominator. Although both Mark Dominus and chromatic have written about it recently, I like Randal Schwartz's phrasing best: "Sooner or later you're going to have to write in Perl." I'm dealing with PHP code at work where the original programmer did not use keyed lookups (PHP arrays are effectively ordered versions of Perl hashes) to check to see if a given string was in a list of special strings. I'm assuming that he was unaware of the ability to look up array elements by key, but I think it would be even worse if he specifically didn't use the feature out of fear, or worrying about future programmers not knowing what the code did.

Assuming that you're a 20% programmer (and that you're reading a programming blog suggests that you are), how do you deal with 80% programmers? Any tricks for the rest of us?

Addendum: Not five minutes after I posted this, I found this article "What if powerful languages and idioms only work for small teams?", with most of the value in the comments from readers.

MJD's recent blog post on undefined behavior takes you into some nitty-gritty of Perl internals and bizarre little behaviors you may not have seen before, plus side trips into Haskell and XML.

Welcome to Mechanix

| | Comments (0)

Mechanix is the new tech section of Perlbuzz that will deal with tech tips, code tricks and other nitty-gritty bits of Perl and related topics. The name "Mechanix" is intentionally vague, not limited to any specific part of Perl, or indeed Perl at all.

About this Archive

This page is a archive of recent entries written by Andy Lester in November 2007.

Andy Lester: December 2007 is the next archive.

Find recent content on the main index or look in the archives to find all content.

Other Perl Sites

Other Swell Blogs

  • geek2geek: An ongoing analysis of how geeks communicate, how we fail and how to fix it.