Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

permutation of hash variables

Status
Not open for further replies.

ctdrummer

Programmer
Dec 17, 2012
1
US
I have a hash as follows:
$result{1}{1}="1-1";
$result{1}{2}="1-2";
$result{1}{3}="1-3";

$result{2}{1}="2-1";
$result{2}{2}="2-2";
$result{2}{3}="2-3";
$result{2}{4}="2-4";

$result{3}{1}="3-1";
$result{3}{2}="3-2";

I would like to be able to produce every possible combination of the sets (the first key) within this hash, i.e.
1-1,2-1,3-1
1-1,2-1,3-2
1-1,2-2,3-1
etc

The number of sets can be variable which i think is where I'm having a problem. I would normally just make concentric loops but if the number of sets is variable I'm having a tough time figuring out how to loop through the sets to give me the combinations. Any suggestions?

Thanks,
Jay
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top