Yet
dws is right. This works for me:
use CGI qw/:standard/;
my %params = map { $_ => scalar param($_) } param();
print '-->' . $params{'listname'}. '<--' . "\n";
Note that I added a "
scalar".
The error was produced by three things:
- You're trying to use A => B as an expression for map, which doesn't work, as "=>" is actually a comma. So map only saw the "A" as the expression, and the "B" as the first item of the list fed to it.
- You used single quotes around "$_" which made CGI.pm look for the parameter "'$_'", literally, which doesn't exist. Combine that with...
- You used param() in a list context, which for a non-existing parameter produces an empty list. "scalar" fixes that.
So, in summary, you were filling %params with a list ( 'listname', 'wtf' ), as everything else dropped away.