in reply to confused with a hash which contains reversed keys

You can reverse strings (i.e. hash keys) using the reverse function. Using that you can loop through all the hash keys and look up the value of the reversed key.

What I don't see is how you'd know which of the 2 keys is the reversed one for each pair.

  • Comment on Re: confused with a hash which contains reversed keys

Replies are listed 'Best First'.
Re^2: confused with a hash which contains reversed keys
by dwm042 (Priest) on Dec 03, 2007 at 19:10 UTC
    There is a ton of similarity between this hash and a symmetric matrix. So, the choice of which symmetric element to be the right one and the reversed one is arbitrary. Since the indices are alphabetical, then alphabetical order makes the most sense. Use the alpha pair where the first letter is earlier in the alphabet. ikegami's solution below seems to do that nicely.