# but also you can create r of n objects permutation generator, where r <= n
my $p = Algorithm::Permute->new([1..4], 3);
####
C:\usr\local\share>perl -MAlgorithm::Permute -e "my $p=Algorithm::Permute::->new([1..4],2); while(my @res=$p->next){print qq(@res\n)}"
2 1
1 2
3 2
2 3
3 1
1 3
4 2
2 4
4 3
3 4
4 1
1 4
##
##
C:\usr\local\share>perl -MAlgorithm::Permute -e "my $p=Algorithm::Permute::->new([1..8],5); while(my @res=$p->next){print qq(@res\n)}"
5 4 3 2 1
4 5 3 2 1
4 3 5 2 1
4 3 2 5 1
4 3 2 1 5
5 3 4 2 1
3 5 4 2 1
3 4 5 2 1
3 4 2 5 1
3 4 2 1 5
...
8 1 2 3 4
1 8 2 3 4
1 2 8 3 4
1 2 3 8 4
1 2 3 4 8