[thelist] Processing Multiple selects from drop downlist in perl

Keith cache at dowebs.com
Wed Dec 12 14:27:38 CST 2001


> > I think I need to get the selections into an array or hash (not sure
> > which) and then somehow process the hash/array to enter the
> > selections into my db (mysql)

Someone else asked offlist how to do it with multiple selects, each 
with multiple options, with other types of form elements too, ending 
with all values in a hash with colon delimiters. 

foreach $pair (@pairs){
    ($name, $value) = split(/=/, $pair);
    push(@$name,$value);
    $value=join(":",@$name);
    $form{$name}=$value;
}

The @$name arrays separate the values by select element name  
and keep building with multiple values on each loop and non select 
values don't get joined because there's nothing to join. If you just 
want scaler results instead of a hash use
	$$name=$value;
instead of
	$form{$name}=$value;

Cheers;

keith




More information about the thelist mailing list