I am using the Perl CGI module. If I have HTML like this
<select multiple name="FILTER_SITE">
<option>1</option>
<option>2</option>
</select>
and submit my form I can get something like this in the URL:
[..] FILTER_SITE=1&FILTER_SITE=2
Perl’s my $FILTER_SITE = $cgi->param('FILTER_SITE'); wil capture only the first instance.
How can I make use of both (in this case)? Hack it and parse the referrer myself and add them to an array is my first idea but it’d be a bit messy, then again I’m hardly versed in CGI.pm or Perl.
With Data::Dumper, interestingly
print "<pre>".Dumper($cgi->param('FILTER_SITE')) . "</pre>";
$VAR1 = '1';
$VAR2 = '2';
NOTE: Current documentation (as of 2020 May 29) says this method could cause a security vulnerability. Please check my answer below.
The
parammethod supplies a single value in scalar context and (potentially) multiple values in list context. Read about it here.So if you change your code to, for example
then the array will contain all selected values of the option.
If it suits your code better, you can also write