https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15747

--- Comment #19 from David Cook <[email protected]> ---
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.
_______________________________________________
Koha-bugs mailing list
[email protected]
http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to