Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Assign 2D-Arrays to a hash using a key

by mmartin (Monk)
on Feb 21, 2012 at 16:59 UTC ( #955354=note: print w/ replies, xml ) Need Help??


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



Comment on Re: Assign 2D-Arrays to a hash using a key
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://955354]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (11)
As of 2015-07-03 13:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (53 votes), past polls