<div dir="ltr">So, let me start with a confession - I stopped at sixth form maths.  <div><br></div><div>The programme I am trying to write this evening seeks to combine one element of set A, with one element of set B, one element of set C, etc.</div><div><br></div><div>I don't know beforehand how many sets there will be.   Each set has a different number of members.</div><div><br></div><div>I need to test all the combinations, so that if we have sets A B C, and A has 2 items, B has 5 items, and C has 2 items, we end up with 2*5*2 combinations = 20.</div><div><br></div><div>k possible combinations of items in a single set is conveniently available through Algorithm::Combinatorics.  I've used that elsewhere in this programme but it doesn't seem to handle multiple sets.</div><div><br></div><div>I've spent the last few hours on this, and have started a few ways.  I have something written using recursion, tracking which sets have already been accessed using an arrayref, and passing around a hashref.  But I am seriously bogged down in that "delete the code and start again" sort of way.</div><div><br></div><div>Are there any better ideas that any of you can point me to?<br><br>Thanks,<br><br>Peter</div><div><br></div></div>