in reply to permutations problem

Set::CrossProduct was written specifically for this purpose.
Perl 6 - links to (nearly) everything that is Perl 6.