Do you use the URI module? If you do, then your problems is that the value return by $uri->path doesn't contain the query parameters.
Take a look at the simple test:
use URI;
my $uri = URI->new("http://localhost/test.html?test=1");
print $uri->path . "\n";
Yes I do use the URI module but didn't know what that was until I started doing some more debugging with the help of the examples posted above. I found the problem on my own shortly before reading your post but it's nice to see that you caught it just by looking at the code.
Thank you again to everyone for your help. Donation time :-)