in reply to Next permutation
You can use a module like Algorithm::Permute or Math::Combinatorics.
Or you could write the loops yourself. But really, unless it's for the learning exercise, it's probably not worth it. And if it were for the learning exercise, then you wouldn't be asking us to write the code for you, so I doubt it is.
If I am wrong about that, you should try to read the source code for one or both of those CPAN modules, and see how they do it, and try to code up your own (simplfied) version that uses the bare algorithm. Or you could make an attempt to at least describe the algorithm you'd use to permute by hand, and we could point you to the Perl functions and other constructs which might help you with implementing the algorithm in Perl.
But learning how to use the CPAN modules is a worthwhile learning exercise, in and of itself; so even if you do want to manually implement it, try it with one or both of those modules.
|
|---|