my @keys = qw/a b c/; my @values = qw/foo bar baz/; my %h; @h{ @keys } = @values; ## or . . . @h{ qw/ a b c/ } = qw/foo bar baz/;
The only klunky thing is that you can't initialize a slice and declare the hash with my in one swell foop; gotta do it as two separate statements. See perldata for more on hash slices.
The cake is a lie.
The cake is a lie.
The cake is a lie.
In reply to Re: Making a hash with lists
by Fletch
in thread Making a hash with lists
by knarf
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |