--On Dienstag, 20. November 2001 23:13 -0500 "Scott R. Godin" <[EMAIL PROTECTED]> wrote:
> well if you do it as $in, it passes a reference. if you do it as %in, it > passes the hash. I tend to find the referenced value more > straightforward to work with when using the object-oriented CGI.pm > interface, it being similar. > Ok, I admit I'm not used to work with references; using your advice I now came up with the following code: my $q = new CGI; my $in = $q->Vars; my %hash; foreach my $key (keys %{$in}) { next if ($in->{$key} eq "---"); next if (!$in->{$key}); $hash{$key} = $in->{$key}; $hash{$key} =~ s/---//g;# necessary if there's an unselected select field *and* a text input field with the same name $hash{$key} =~ s/^\0//;# necessary if there are two fields with same name and the first one is empty $hash{$key} =~ s/(\0)$//; # ... when the second one is empty $hash{$key} =~ s/\0/~~/g; } It achieves what I want, taking care of multiple selects, empty values *and* two fields with the same name. Can it still be further simplified? It would be advisable to have some error-checking, when users choose *both* a value from a dropdown list *and* type input into the text field with the same name. But I guess that can't be done without knowing the field name; perhaps pass a hidden name/value-pair with "double" as name and the double field name as value, and if the hash value of that field name contains "~~", return an error message. Anyway, many thanks for the advice, Birgit Kellner -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]