cartman94501 (cartman94501) wrote in perl,

Am I going insane?

This code snippet (line numbers are obviously not part of the code):

137:print "right before the weirdness, url=\|$url\|\n";
138:if ($url =~ /(jpg|gif|png)/i) {
[do something utterly irrelevant here]

sometimes, but not always, causes the following output:

right before the weirdness, url=||
Use of uninitialized value in pattern match (m//) at [scriptname].pl line 138.

We see that $url is non-null, and obviously (jpg|gif|png) is a constant, so how could either side of the pattern match be uninitialized? The script appears to work, but it keeps throwing this error. Oddly, this only started this week ago, and until it happened, I had made no recent changes, either to the code or to Perl.

I lack the necessary hubris to think that I've discovered a bug in Perl, rather than in my humble code, but the mind does boggle.

I am running Perl under Windows XP, SP2. There are 16 registered patches, none of which I installed manually, which I can provide if you think it's relevant.

Thanks in advance for your help!

  • Post a new comment


    default userpic