in reply to Should I use a hash for this?

This is something I'd probably use Set::Scalar for. It does all the set stuff for you.

$hash{g1} = Set::Scalar->new(qw(ATG1 ATG2 ATG4 ATRG7)); $hash{g2} = Set::Scalar->new(qw(ATG1 x y z)); if( $hash{g1}->intersection($hash{g2}) ) { print "merging g1 and g2\n"; $hash{g1}->insert(delete $hash{g2}) }

Not sure if that really answers the question though.

-Paul