Not sure it helps a lot in your case, but this is one possible way to generate permutations in this session under the Perl debugger:

DB<1> @array=qw/a b c d/ DB<2> $stringified = join ',', @array; DB<3> @permutations = glob "{$stringified}" x 2; DB<4> map {s/(.)(.)/$1-$2/} @permutations DB<5> x @permutations 0 'a-a' 1 'a-b' 2 'a-c' 3 'a-d' 4 'b-a' 5 'b-b' 6 'b-c' 7 'b-d' 8 'c-a' 9 'c-b' 10 'c-c' 11 'c-d' 12 'd-a' 13 'd-b' 14 'd-c' 15 'd-d'

Of course, in your case, additional filtering would be necessary. I think that the modules mentionned by other monks are probably a better solution.


In reply to Re: How can one find out the pairwise difference and product between elements in a perl array without using a perl module? by Laurent_R
in thread How can one find out the pairwise difference and product between elements in a perl array without using a perl module? by supriyoch_2008

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.