cspctec has asked for the wisdom of the Perl Monks concerning the following question:
my @fname = ("Bob", "John", Ashley"); my @lname = ("Johnson", "Hill", "Sharp"); my @state = ("AK", "CA", "AL");
And what I am trying to do is create a hash that uses the @fname and @lname as the keys and the @state as the value to the hash.
What is the best way to do this? I have seen examples of using the map function, but I thought you could just set a hash equal to an array and it would create the hash for you.The only problem is I don't know how to make both the first and last name arrays the key at the same time.
Any help would be appreciated.Just to be clear, the hash should be like
{Bob Johnson} => {AK} {John Hill} => {CA}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Creating a hash from arrays
by tangent (Parson) on Nov 02, 2013 at 19:57 UTC | |
|
Re: Creating a hash from arrays
by davido (Cardinal) on Nov 02, 2013 at 20:13 UTC | |
by cspctec (Sexton) on Nov 02, 2013 at 22:24 UTC | |
by BrowserUk (Patriarch) on Nov 02, 2013 at 22:58 UTC | |
by cspctec (Sexton) on Nov 02, 2013 at 23:25 UTC | |
by AnomalousMonk (Archbishop) on Nov 02, 2013 at 23:38 UTC | |
by Laurent_R (Canon) on Nov 03, 2013 at 16:43 UTC | |
by marinersk (Priest) on Nov 03, 2013 at 01:31 UTC | |
by AnomalousMonk (Archbishop) on Nov 02, 2013 at 22:42 UTC | |
by cspctec (Sexton) on Nov 02, 2013 at 22:56 UTC | |
by AnomalousMonk (Archbishop) on Nov 02, 2013 at 23:30 UTC | |
by LanX (Saint) on Nov 02, 2013 at 23:32 UTC | |
by tangent (Parson) on Nov 03, 2013 at 16:53 UTC | |
|
Re: Creating a hash from arrays
by Kenosis (Priest) on Nov 02, 2013 at 20:02 UTC | |
|
Re: Creating a hash from arrays
by Eily (Monsignor) on Nov 02, 2013 at 21:34 UTC |