perrin has asked for the wisdom of the Perl Monks concerning the following question:

I want to get the names and values from a select list that I'm parsing with HTML::Form as a hash. I came up with one way to do it, but it feels kludgy:
my %hash; @hash{ $input->value_names() } = $input->possible_values();
Can anyone suggest something better?

Replies are listed 'Best First'.
Re: HTML::Form and select values (better?)
by Aristotle (Chancellor) on Nov 11, 2003 at 01:38 UTC
    For some definition of "better":
    my %hash = do { my @key = $input->value_names(); (@key, $input->possible_values())[ map { $_ => $_ + @key } 0 .. $# +key ] };
    It has bugged me many times that there's no native way to "weave" two arrays in Perl. (Maybe there's an idea for a List::Util addition..)

    Makeshifts last the longest.