From my Perl blooper reel

jjohn on 2002-04-10T15:08:19

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 otherwords, 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!


You are not alone...

gtod on 2002-04-10T16:38:36

My oh my oh my. :-)

Re:You are not alone...

ajtaylor on 2002-04-17T14:02:45

That was perfect! I almost made a fool of myself laughing here at work. ;-)

heh

jmm on 2002-04-10T16:55:59

You're my kind of idiot.

Hah!

ct on 2002-04-11T14:51:54

Though, I've done it myself.