http://www.perlmonks.org?node_id=955354


in reply to Assign 2D-Arrays to a hash using a key

Hey guys thanks for your help,

Ok so the thing with the array that it might have more then one value for a particular key, I was able to work around. Since the "values" that would have multiples were integers I just simply added them together then re-assigned the "temporary" array back to the original empty array. So that part is fixed...


So for assigning to a hash I was able to find some older scripts I wrote that had hashes and was able to use that and figure it out.

So since there were 5 different 2D-Arrays I came up with this to build the hash:
###These were the names of the arrays my (@AP_name, @AP_ipAddress, @AP_IOSversion, @AP_channelUtil, @AP_numC +lients); ################################################################### for (my $x = 0; $x <= $#AP_name; $x++) { $AP_data{ "$AP_name[$x][0]" } = { NAME => "$AP_name[$x][1]", IPADDRESS => "$AP_ipAddress[$x][1]", VERSION => "$AP_IOSversion[$x][1]", UTILIZATION => "$AP_channelUtil[$x][1]", NUMCLIENTS => "$AP_numClients[$x][1]" }; }

And since the arrays are already presorted when I collect the data it made it much easier to build the hash and not have to worry about comparing the Key/identifiers...


Thanks for your help..!

Thanks,
Matt