You get exactly the same result if you do this:
my %webobj = (
'template' => ,
'minscale' => 2
);
because there is no param(template), so it's like you said 'template' => nothing, comma, minscale, I guess.
I suppose this is somehow different to doing it with an undefined variable -- that way you'd get undef as the value for 'template'.
I know it's daggy and old-fashioned, but if I'm in a hurry, I just do this:
CGI::ReadParse();
which puts everything into a hash called %in. That was only included in CGI.pm for backward, perl 4/cgi-lib compatibility, but I like it. It does what you're trying to do here, right?
--
Every bit of code is either naturally related to the problem at hand, or else it's an accidental side effect of the fact that you happened to solve the problem using a digital computer.
M-J D | [reply] [d/l] [select] |
use CGI qw(:cgi-lib);
my $form = Vars;
Gives you a tied hash-reference to all parameters, also allowing you to change the submitted parameters...
| [reply] [d/l] |
thanks, that also works... so my choices are
my %webobj = (
'template' => param('template') || '',
'minscale' => param('minscale') || ''
);
or
my %webobj = (
'template' => scalar(param('template')),
'minscale' => scalar(param('minscale'))
);
From Randal's comment it seems the latter would be the wiser choice.
I am assuming 'minscale' is being assigned as a value to the 'template' key because there is nothing in param('template') and the comma is causing minscale to appear as part of a list. | [reply] [d/l] [select] |