in reply to How to make a hash out of two arrays,one with keys and other with values?
Very simply:
my %hash; @hash{@Arrayone} = @Arraytwo;
See hash slices in perldata.
You could also do it in one statement with the help of map.
my %hash = map { $Arrayone[$_] => $Arraytwo[$_] } 0..$#Arrayone;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to make a hash out of two arrays,one with keys and other with values?
by educated_foo (Vicar) on Jun 30, 2009 at 13:44 UTC |