As shown in the Algorithm::Permute synopsis, if you want r elements out of the n objects in each permutation,
# but also you can create r of n objects permutation generator, where +r <= n my $p = Algorithm::Permute->new([1..4], 3);

A practical example is shown here, where there are n=4 objects and I take groups of r=2:

C:\usr\local\share>perl -MAlgorithm::Permute -e "my $p=Algorithm::Perm +ute::->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

Your example would be ...->new([1..8],5) to get permutations of length 5 from the 8 objects given. Or

C:\usr\local\share>perl -MAlgorithm::Permute -e "my $p=Algorithm::Perm +ute::->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

In reply to Re: Getting permutations of length n of an array of length greater than n? by pryrt
in thread Getting permutations of length n of an array of length greater than n? by LittleJack

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.