my %query = parse_form_data( ) or error( "Invalid request" );
my @numbers = ref( $query{numbers} ) ? @{ $query{numbers} } : $query{numbers};
This syntax is awkward. Another approach is to store the multiple
values as a single text string that is delimited by a certain
character, such as a tab or "\0". This
is easier to code in the subroutine:
if ( exists $form_data{$name} ) {
$form_data{$name} .= "\t$value";
else {
$form_data{$name} = $value;
}
It is also easier to read in the CGI script:
my %query = parse_form_data( ) or error( "Invalid request" );
my @numbers = split "\t", $query{numbers};
However, there is still a potential for corrupted data if the CGI
script is not expecting multiple values.