simeon2000 has asked for the wisdom of the Perl Monks concerning the following question:
I've got two arrays.
@keys = qw/size atime ctime/; @vals = (101, 12, 13);
The end result I want is:
%hash = ('size' => 101, 'atime' => 12, 'ctime' => 13);
Is there a one/two liner to combine those two arrays into a hash? I can make a simple for loop to do it, but I'd like to do it in a one liner and impress all my friends and relatives. Anyone?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(Ovid) Re: Creating a hash from two arrays
by Ovid (Cardinal) on Mar 27, 2002 at 16:29 UTC | |
by Dragonfly (Priest) on Mar 27, 2002 at 19:52 UTC | |
by wardk (Deacon) on Mar 27, 2002 at 23:59 UTC | |
by Ovid (Cardinal) on Mar 28, 2002 at 00:58 UTC | |
|
perldoc perldata
by Fletch (Bishop) on Mar 27, 2002 at 16:25 UTC | |
|
Re: Creating a hash from two arrays
by particle (Vicar) on Mar 27, 2002 at 17:01 UTC | |
|
Re: Creating a hash from two arrays
by insensate (Hermit) on Mar 27, 2002 at 16:42 UTC |