in reply to permutations problem

Algorithm::Loops's NestedLoop is exactly what you need.
use Algorithm::Loops qw( NestedLoops ); my @inputs = ( [qw( 1 2 )], [qw( a b )], [qw( $ * & )], ); my $iter = NestedLoops(\@inputs); while ( my @list = $iter->() ) { print(join(',', @list), "\n"); }

It doesn't build the result set in advance. It uses minimal memory by only generating the next permutation when requested.