hi all -
got a bit of a tricky problem, not even sure if there is a way to do it, but i'll happily be proved wrong!!
i have a hash of arrays, generated from a file that looks like this:
and so on. i have had no problem reading this file into a hash of arrays, what i would like to do is this - some of the values in the arrays associated with each hash key are the same, and i would like to identify these. so for example if the hash looks like this:
where the names are keys and the 'attributes' are values in the associated array, i'm trying to design something that can identify matches and therefore return that both id1 and id2 are red, and that both id1 and id3 are green.
hope that makes sense... i have tried various approaches of cycling through the associated arrays but can't seem to find an effective ways of comparing all the arrays and finding matches, to return the appropriate keys.
if anyone can suggest a good way to approach the problem i'd be very grateful, thanks!
got a bit of a tricky problem, not even sure if there is a way to do it, but i'll happily be proved wrong!!
i have a hash of arrays, generated from a file that looks like this:
Code:
id val val val
id val
id val val
and so on. i have had no problem reading this file into a hash of arrays, what i would like to do is this - some of the values in the arrays associated with each hash key are the same, and i would like to identify these. so for example if the hash looks like this:
Code:
id1 (red, green, blue)
id2 (red)
id3 (green, yellow)
where the names are keys and the 'attributes' are values in the associated array, i'm trying to design something that can identify matches and therefore return that both id1 and id2 are red, and that both id1 and id3 are green.
hope that makes sense... i have tried various approaches of cycling through the associated arrays but can't seem to find an effective ways of comparing all the arrays and finding matches, to return the appropriate keys.
if anyone can suggest a good way to approach the problem i'd be very grateful, thanks!