in reply to Merging 2 hashes - updated again

I'm curious, since i haven' done anything like this with switches, i know a little and thus a few simple questions.

Are you trying to create two hashes and see how much of one matches the other? Meaning is there a reason why one while is inside the other one?
Thing that is strange to me also is that you seem to replace entire hash in both hashes within each while loops pass (although this might come from my limited understand of how to pass values into hash) or is this intentional?

Replies are listed 'Best First'.
Re: Re: Merging 2 hashes - updated again
by rspence (Initiate) on Oct 31, 2003 at 00:46 UTC
    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