A google search for "perl combinations and permutations" yielded Permutations and combinations. Since you are creating permutations of the given arrays, the name of the subroutine should probably be permute:

print "[", join(", ", @$_), "]\n" for permute( [qw( red green blue )], [qw( north south east west )], [1 .. 3], ); # authored by merlyn sub permute { my $last = pop @_; unless (@_) { return map [$_], @$last; } return map { my $left = $_; map [@$left, $_], @$last } permute(@_); } __DATA__ [red, north, 1] [red, north, 2] [red, north, 3] [red, south, 1] [red, south, 2] [red, south, 3] [red, east, 1] [red, east, 2] [red, east, 3] [red, west, 1] [red, west, 2] [red, west, 3] [green, north, 1] [green, north, 2] [green, north, 3] [green, south, 1] [green, south, 2] [green, south, 3] [green, east, 1] [green, east, 2] [green, east, 3] [green, west, 1] [green, west, 2] [green, west, 3] [blue, north, 1] [blue, north, 2] [blue, north, 3] [blue, south, 1] [blue, south, 2] [blue, south, 3] [blue, east, 1] [blue, east, 2] [blue, east, 3] [blue, west, 1] [blue, west, 2] [blue, west, 3]

As you can see, his method returns a list of permutations, and each permutation is contained inside an array reference. By doing this, he has deferred the decision of formatting the output to the client and he does not have to worry about that portion of the code, which has been distilled to a simple print "[", join(", ", @$_), "]\n" for permute().

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

In reply to Re: RFC: Playing with glob by jeffa
in thread RFC: Playing with glob by Lady_Aleena

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.