in reply to Re: Merging 2 hashes - updated again
in thread Merging 2 hashes - updated again

Hi Hena, First things first - my goal is to build a list of MAC_addr->switch_port pairings in "real-time". One can do this with managed switches. Unfortunately I am dealing with layer 2 switches and due to the environment I work in certain Cisco functions must be turned off. The only way to reach my goal, that I've found (even on Cisco's site) is to combine the output of 3 different OIDs. (Assuming you know what an OID is...). Anyway, generally speaking, I end up with 3 hashes: A->B B->C C->D. Thus my post - my end goal is A->D. Also: the following is true; for every A ther is a C, and for every B there is a D, so my perl task is to iterate over every A, match its B with the corresponding C in the second hash, then match that C (key) with its corresponding D (value) in the third hash. (FYI A=MAC_addr, B=bridge port ID, C=ifIndex (Interface Index #) and D=switch_port#). I hope that clarifies at least my goal. To answer your questions - switching the values while inside the while loops is the only way I found to match A->C. I found that when I close the 2 loops, in order, the "matching" logic at the end only sees the last key->value pair in each hash. This is why I wondered if I should be utilizing references instead of playing with the "real" values in memory. (Or I should go ahead and try my original nested loop approach that the monks have officially frowned upon. :) ) Anyway - being my usual verbose self. Thanks, rspence
  • Comment on Re: Re: Merging 2 hashes - updated again