Hi

I have two discontinuous sets of values and some pairs from each sets are "valid" and have assigned values, for example:

`# subset 1 of (A..Z)
set_1 = (A, B, C, X, Y, Z)
# subset 2 of (a..z)
set_2 = (q, w, r, t, u)
# valid pairs
valid = ((A,q) = 1, (A,u) = 6, (A,k) => 3, (C,t) = 10, (Z,u) = 30)
`

I have a problem with "translating" this to perl. I know I need some kind of map for storing information about valid pairs and their id (like python's map of tuples: (x,y) => z). But having two sets, each consisting of 100 elements requires 100x100=10000 combinations... Is there any quicker method for this?

If I'd have an index like this:

`my %INDEX = {
A => { q => 1, u => 6, k => 3 },
C => { t => 10 },
Z => { u => 30 },
M => { q => 100 }
}
`

I could narrow search by creating intersection (e.g. using Set::Object):

`# narrow by first set
(set_1) x (keys %INDEX) = (set_1) x (A, C, M, Z) = (A, C, Z)
`

then i would be left with an array of hash-refs and do:

`set_2 x (q, u, k) + set_2 x (t) + set_2 x (u) = (1, 6, 10, 30)
`

I don't like this idea though and I don't know if it would be faster than combinations hash checks. Is there a perl module that would help me with this?