in reply to Getting Pairs of 2nd-ary Keys in HoHoA

As always, TIMTOWTDI :P
my @sets = sort(keys(%HoHoA)); while(@sets) { my $set1 = shift(@sets); foreach my $part1 (sort(keys(%{$HoHoA{$set1}}))) { #note that the earlier shift has already taken off #the part we don't want to match against foreach my $set2 (@sets) { foreach my $part2 (sort(keys(%{$HoHoA{$set2}}))) { print "$part1 - $part2\n"; } } } }
Note that this is still pretty damn inefficient because it sorts the sets of keys to match with every time it goes through the loop, but then again, this *does* sound like a school assignment, so that part is up to the OP. What looks to me to be the most efficient solution is to first make a pass through the entire HoH(the fact that the keys point at arrays in this specific case is entirely irrelevant) and make a sorted array for each set of keys and assign these to a HoA instead. Then, once the sorting is done you could simply foreach through the HoA and do the matching you wanted. If this is indeed, as i expect, a school assignment the latter solution would be, especially when the data gets bigger, a lot more efficient than the one I gave you and thus get you a better grade ;-)


Remember rule one...