new_2_perl wrote:
When the user submits the form my $input will only give me the last value from the list box they selected.
I see this all the time and it's invariably from someone who is using a broken "hand-rolled" alternative to CGI.pm. CGI.pm, if you ask for the form's value in scalar context, will return the first value for the form element in question. Alternatives to CGI.pm, however, often have code like the following:
foreach $pair (@pairs){
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%0D%0A/\n/g;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
There are a variety of problems with this, but the line that usually causes problems like what you are experiencing is the $FORM{$name} = $value; line. This one will simply overwrite the last value of $FORM{$name} rather than adding a new value.
See "use CGI or die;" for more complete information as to why using alternatives to CGI.pm are usually a poor idea.
Cheers,
Ovid
Vote for paco!
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats. |