Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
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 having an uproarious good time at the Monastery: (8)
As of 2014-12-23 00:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (133 votes), past polls