in reply to How can one generate all possible permutations of r elements out of n where r<n?
A very fast look on CPAN reveals Math::Combinatorics
Despite the low version number, it looks as though it does what you want, and if it doesn't the source code is probably a good starting point to modify to do it.
IIRC a lot of advice round here advises Googling and checking CPAN, because it's probably been asked before :-).
A Monk aims to give answers to those who have none, and to learn from those who know more.