in reply to CGI Ensure Array
Well, your main question is nice and easy, and nearly all that complexity can go. CGI.pm will return input parameters as an array if asked for them in array context, however many there are. So:
use CGI; my $input = new CGI; my @var = $input->param('var');
should work without your having to pad the form or check the browser type. tests with:
use CGI; use Data::Dumper; my $input = new CGI; my @var = $input->param('var'); print "Content-type:text/plain\n\n"; print Dumper \@var;
seem to confirm that it works. But anyway, if you _really_ want to load the input into a namespace (why?), you don't have to go through all those hoops to do it:
my $query = new CGI; $query->import_names('input');
will import the entire parameter set into an input:: namespace, and you can then just ask for @input::arrayparam to get values in array form. But you lose a lot of power this way: it's hard to iterate over the set of input parameters, for example. I would suggest using the object-oriented interface to CGI instead, if you can, and passing around the CGI object if necessary. It's safer, more flexible and more friendly to later development than this approach, which seems very vulnerable to me.
But i confess i'm slightly baffled by the javascript part - can't see what it's doing for you - so perhaps am up wrong tree entirely?
|
|---|