[thelist] Processing Multiple selects from drop downlist in perl

Adrian Fischer adrian at aussiebidder.com
Wed Dec 12 14:50:17 CST 2001


Hello Keith,

As I said, I understand the theory.  Its the application that stumps me.
Here is my parsing routine.  How do I massage what you've said into it?  Or
am I barking up the wrong tree here?

<snip>
####FORM DATA
sub get_form_data {
        my $temp;
        my $buffer;
        my @data;
        read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
        foreach $temp (split(/&|=/,$buffer)) {
                $temp =~ tr/+/ /;
                $temp =~ s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge;
	$temp=~ s/\cM/ /gs;
$temp=~ s/\n\n/<P>/gs;
$temp=~ s/\n/<BR>/gs;
                push @data, $temp;
        }
        foreach $temp (split(/&|=/,$ENV{'QUERY_STRING'})) {
                $temp =~ tr/+/ /;
                $temp =~ s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge;
		$temp=~ s/\cM/ /gs;
$temp=~ s/\n\n/<P>/gs;
$temp=~ s/\n/<BR>/gs;
                push @data, $temp;
        }
        return @data;
}
</snip>

Am I comming across as a complete numpty?

Regards

Adrian Fischer



> Perhaps putting all the selections from the drop down into a variable
> delimited by : or ; and inserting that into the column in the db?

That's how I do it. Say the select is named "xx" and user selects 3
oprtions, 3 separate xx=value arrive at the server. So in the parsing
routine I push then into an array instead of hashing them

if($name eq "xx){push(@xx,$value)}
else{$form{$name}=$value}

then later

$xx=join(":", at xx);

keith





More information about the thelist mailing list