This might help?
There are duplicates, eg 12 and 21.
#!/usr/bin/perl use strict; use warnings; my @perms = glob "{1,2,3}" x 3; print "@perms\n"; @perms = glob "{1,2,3}" x 2; print "@perms\n"; __END__ Prints: 111 112 113 121 122 123 131 132 133 211 212 213 221 222 223 231 232 23 +3 311 312 313 321 322 323 331 332 333 11 12 13 21 22 23 31 32 33
Another run:
#!/usr/bin/perl use strict; use warnings; my @perms = glob "{a,b,c,d,e}" x 3; print "@perms\n"; print "\n"; @perms = glob "{a,b,c,d,e}" x 2; print "@perms\n"; __END__ Prints: aaa aab aac aad aae aba abb abc abd abe aca acb acc acd ace ada adb ad +c add ade aea aeb aec aed aee baa bab bac bad bae bba bbb bbc bbd bbe + bca bcb bcc bcd bce bda bdb bdc bdd bde bea beb bec bed bee caa cab +cac cad cae cba cbb cbc cbd cbe cca ccb ccc ccd cce cda cdb cdc cdd c +de cea ceb cec ced cee daa dab dac dad dae dba dbb dbc dbd dbe dca dc +b dcc dcd dce dda ddb ddc ddd dde dea deb dec ded dee eaa eab eac ead + eae eba ebb ebc ebd ebe eca ecb ecc ecd ece eda edb edc edd ede eea +eeb eec eed eee aa ab ac ad ae ba bb bc bd be ca cb cc cd ce da db dc dd de ea eb ec e +d ee

In reply to Re: Sum of N elements in an M element array by Marshall
in thread Sum of N elements in an M element array by abhay180

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.