[Koha-bugs] [Bug 15747] Auth.pm flooding error log with "CGI::param called in list context"
bugzilla-daemon at bugs.koha-community.org
bugzilla-daemon at bugs.koha-community.org
Tue Feb 16 00:44:54 CET 2016
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15747
--- Comment #19 from David Cook <dcook at prosentient.com.au> ---
So yeah, even if you use the [] to create an arrayref, you'll still get the CGI
warning, because CGI just knows you're asking for a single named parameter in
list context; it doesn't know that you're going to create a reference using
that list.
But... even if you were using CGI->multi_param... you'd still need to use the
[] construct to use an arrayref for a hash value rather than accidentally
filling your hash full of other values because you added a list...
Anyway, here's some easy tests to run:
--------
BAD NEWS:
use Modern::Perl;
use CGI;
use Data::Dumper;
my $query = CGI->new();
$query->param('name',"bruce","wayne","clark","kent");
my %hash = (
id => 1,
name => $query->param('name')
);
warn Dumper(\%hash);
--------
WELL DONE:
use Modern::Perl;
use CGI;
use Data::Dumper;
my $query = CGI->new();
$query->param('name',"bruce","wayne","clark","kent");
my %hash = (
id => 1,
name => [$query->param('name')]
);
warn Dumper(\%hash);
---------
HALFWAY THERE:
use Modern::Perl;
use CGI;
use Data::Dumper;
my $query = CGI->new();
$query->param('name',"bruce","wayne","clark","kent");
my %hash = (
id => 1,
name => scalar $query->param('name')
);
warn Dumper(\%hash);
--
You are receiving this mail because:
You are watching all bug changes.
More information about the Koha-bugs
mailing list