Hello, fellow Monks! I am not a mathematician, so I am sure there's a word for this out there. I want to generate every possible combination of words taken from an array. The array will have words, I want it to be like this: @array = qw( hey foo bar ); Output:
hey
foo
bar
hey foo
hey bar
hey hey
hey foo bar
hey foo hey
hey foo foo
And so on... I would love the ability to control the number of repetitions allowed in the output, and haven't been able to find any module to do so. Data::Random does a nice job of randomly selecting random numbers of elements, but I want a linear way of generating them - It is for a test suite for a program I'm writing right now. Any help would be greatly appreciated!

In reply to Generating sequence of words by Apocalypse

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.