Subject: | BUG $query->Vars tied hash regression: exists() now fails, worked before |
Date: | Thu, 3 Jul 2008 12:21:20 +0700 |
To: | bug-CGI.pm [...] rt.cpan.org |
From: | "Chris Pirazzi" <chris [...] pirazzi.net> |
CGI.pm version: 3.38
Perl version: v5.8.8 built for i686-linux
Linux 2.6.9-67.0.7.ELsmp #1 SMP Sat Mar 15 06:54:55 EDT 2008 i686
i686 i386 GNU/Linux
This is something which has broken in the last few months, though I'm not sure
exactly which version of CGI caused it.
When you use the tied hash returned by $query->Vars, exists() always
returns false. It used to return the correct value. There is an EXISTS
routine (autoloaded) in CGI.pm but I cannot figure out why it is not
used/working.
Run the following short script to see the problem:
#!/usr/bin/perl
use English;
use strict;
use CGI qw/-oldstyle_urls/; # use '&' in $query->query_string, not ';'
use CGI::Util;
my $query = new CGI();
my $inparams = {$query->Vars}; # plain hash
my $inparams2 = $query->Vars; # tied hash
print "Content-Type: text/html\n\n";
foreach my $k (keys %$inparams)
{
print "[$k] [$inparams->{$k}] [" . exists($inparams->{$k}) .
"] [" . exists($inparams2->{$k}) . "]<br>\n";
}
Notice how the real hash gives you 1 for exists, but the tied hash
gives you 0.