in reply to Input arrays to CGI

CGI.pm will handle this. All you need to do is request the multi-value parameter as a list:
use strict; use CGI qw(param); use Data::Dumper; my @list = param('list'); print Dumper \@list;
Run this on the command line like so:
./foo.pl 'list=foo&list=bar&list=baz&list=qux'
and you should see the following:
$VAR1 = [ 'foo', 'bar', 'baz', 'qux' ];

Replies are listed 'Best First'.
Re^2: Input arrays to CGI
by hippo (Archbishop) on Nov 14, 2024 at 17:06 UTC

    Note that since CGI.pm version 4.05 (released in 2014) using this approach will cause a warning to be emitted regarding the potentially unsafe nature of it. You can improve the safety (and by doing so avoid the warning) by calling multi-param instead.

    #!/usr/bin/env perl use strict; use warnings; use CGI qw(multi_param); use Data::Dumper; my @list = multi_param ('list'); print Dumper \@list;

    🦛