TASdvlper has asked for the wisdom of the Perl Monks concerning the following question:
I have two arrays of equal sizes, is there a way I can use one array for the "keys" of a hash and the other array the "values" of a hash (assuming 1:1 mapping) ?
and I want the hash to look like:@array1 = qq (foo, foo1, foo2, foo3, foo4, ...) @array2 = qq (bar, bar1, bar2, bar3, bar4, ...).
Any help would be greatly appreciated.$myhash{'foo'} = 'bar'; $myhash{'foo1'} = 'bar1'; $myhash{'foo2'} = 'bar2'; $myhash{'foo3'} = 'bar3'; $myhash{'foo4'} = 'bar4';
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Populating a hash from array
by jeffa (Bishop) on Jan 05, 2004 at 21:36 UTC | |
by TASdvlper (Monk) on Jan 05, 2004 at 21:48 UTC | |
|
Re: Populating a hash from array
by duff (Parson) on Jan 05, 2004 at 21:36 UTC | |
|
Re: Populating a hash from array
by Abigail-II (Bishop) on Jan 05, 2004 at 21:36 UTC | |
|
Re: Populating a hash from array
by bart (Canon) on Jan 05, 2004 at 22:03 UTC | |
by TASdvlper (Monk) on Jan 07, 2004 at 15:05 UTC | |
by Limbic~Region (Chancellor) on Jan 07, 2004 at 15:27 UTC | |
|
Re: Populating a hash from array
by Roger (Parson) on Jan 05, 2004 at 22:36 UTC | |
|
Re: Populating a hash from array
by ryantate (Friar) on Jan 05, 2004 at 21:55 UTC | |
by runrig (Abbot) on Jan 05, 2004 at 22:06 UTC | |
by ysth (Canon) on Jan 06, 2004 at 06:56 UTC | |
by tye (Sage) on Jan 06, 2004 at 07:33 UTC | |
|
Re: Populating a hash from array
by Anonymous Monk on Jan 06, 2004 at 18:55 UTC |