perlquestion
mmartin
Hello Monks,<br>
<br>
I'm trying to assign the values from a couple of 2-D Arrays into a hash based on a "key" within the array.<br>
I haven't messed with hashes in a while so I'm a little rusty. I'm having trouble figuring out how to assign the values, I looked for an example online but alas Google has failed me lol...<br>
<br>
What I have is 5 separate 2-Dimensional Arrays. All arrays have the same setup.<br>
<b>For Example: @myArray[key][value]</b><br>
<code>
### I'm using 5 separate arrays but for the sake of space I'll just do 3 here...
$first[0][0] = "111"
$first[0][1] = "on"
$first[1][0] = "222"
$first[1][1] = "off"
$first[2][0] = "333"
$first[2][1] = "null"
...etc...
############################
$second[0][0] = "111"
$second[0][1] = "10.1.1.1"
$second[1][0] = "222"
$second[1][1] = "12.1.1.1"
$second[2][0] = "333"
$second[2][1] = "13.1.1.1"
...etc...
############################
$third[0][0] = "111"
$third[0][1] = "12.1(SAG1)"
$third[1][0] = "222"
$third[1][1] = "12.4(FCL5)"
$third[2][0] = "333"
$third[2][1] = "12.1(5)"
...etc...
############################
### Then have a hash with all the values combined.
# i.e. the hash should look something like this after a 'Data::Dump':
#--------- %all_data ---------#
VAR1 = '111' => "on",
=> "10.1.1.1",
=> "12.1(SAG1)";
VAR2 = '222' => "off",
=> "12.1.1.1",
=> "12.4(FCL5)";
VAR3 = '333' => "null",
=> "13.1.1.1",
=> "12.1(5)";
</code>
<br>
I'm having trouble figuring out if I need a loop or what not, because not all the arrays are the same length.<br>
Occasionally a couple of the arrays might have more than one value for a particular key...<br>
i.e. It might have 2 values like this below for the key "111".<br>
$fourth[111][125]<br>
$fourth[111][200]<br>
<br>
<br>
If anyone has any hints that could point me in the right direction that would be great...<br>
I've read the PerlDocs on hashes but I am still a little confused.<br>
<br>
<br>
Thanks in Advance,<br>
Matt<br>
<br>