in reply to recursively generating permutations
You should look at Algorithm::Loops, and, through Super Search, to the following PM links:
- Permutations and combinations
- Permuting with duplicates and no memory
- Non- recursive permutation of arrays.
In Section
Seekers of Perl Wisdom