Here’s some fun at my expense. This kept me in stitches for most of yesterday. After a good night’s sleep (and more methodical debugging), I tracked the problem down to this block:

sub find_referral_by_ip {
  my($self, $ip, $dbh) = @_;

  # ... non-related code omitted

  unless($ip){
    my $ip = $r->connection->remote_ip;
  }

The intention here is to get the IP address of the current request if it wasn’t passed in (yup, it’s mod_perl). In other words, if $ip isn’t populated then ensure it is. Normally, I don’t pass in the IP, since this method will figure out the IP on its own, right? I began wondering: “should I be looking a subrequest? Is my sql [not shown here] broken? What’s going on here?!”

Have you seen the problem yet? Here’s a hint: it has NOTHING to do with mod_perl, a bug in Perl or the way Perl handles method calls.

The upshot is that I’m an idiot.

Thank you!

[Original use.perl.org post and comments.]