http://www.perlmonks.org?node_id=899170


in reply to Generating all possible combinations from an AoA

When you have an indeterminate level of nesting, it is good to think about recursive solutions (as in JavaFan's solution).