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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|