in reply to Get the difference between 2 Hashes
As for his remark about the problem with your sample data, I would take that a little further -- I wasn't really sure what your criteria are for the particular values you want as output:
Anyway, I wonder if your hash structure really needs to have so many layers. Is there anything besides "MachineType" at the top level? Anything besides "Unit" at the third level? In other words, couldn't the structure really be like this:
For that matter, you could flatten this out, and make the comparisons trivially simple, by just concatenating the keys into a single string, instead of using them as separate layers:$values{Blue_machine}{2}{0}{19} $values{Red_machine}{1}{0}{22} ...
How are you loading up the hash stuctures in the first place? (An xml parse? I suppose it might be easier in some sense to stick with the deep structure if that's the case, though I'd still look for a way to refactor the parsing to allow a flatter data structure.)$values{"Blue_2_0_19"} $values{"Red_1_0_22"} ...
|
|---|