Hi i am working on a script in perl i have seen codes for permutation but my problem is i have an array with values say @array =(john, cena , barrack, obama, donald, trump) value at index 0 is first name and at 1 is last name at 2 is first name again and at 3 is last name and so on. so it should be like

```
john cena
barrack obama
donald trump

```

i need permutation for this combination

```
barrack obama
donald trump
john cena

donald trump
john cena
barrack obama

```

like this 
how this can be done!!
I have done this with hard coding but i need to make it more generic !

```
            my $i=0;
            my @array;
            print $fh_testcases "\n${indentation}${tab}$tab'$intent_json_result': [[\n";
            while ((my $key, my $value) = each %{@{$p_phrase_recogslots}[${speech_phrase_counter}-1]}) {
                $array[$i]= $key;
                $array[$i+1]= $value;
                $i= $i+2;
            }
            if ($i == 6){
                print $fh_testcases "${indentation}${tab}$tab$tab(\"$array[0]\", \"$array[1]\"),\n";
                print $fh_testcases "${indentation}${tab}$tab$tab(\"$array[2]\", \"$array[3]\"),\n";
                print $fh_testcases "${indentation}${tab}$tab$tab(\"$array[4]\", \"$array[5]\"),\n";
                print $fh_testcases "${indentation}${tab}$tab$tab(\"origin\", \"onboard\")\n"; #TODO handle offboard cases
                print $fh_testcases "${indentation}${tab}$tab]]\n";
                print $fh_testcases "${indentation}${tab}},\n";

                print $fh_testcases "${indentation}${tab}\{'$intent_json_result': [[\n";
                print $fh_testcases "${indentation}${tab}$tab$tab(\"$array[4]\", \"$array[5]\"),\n";                    
                print $fh_testcases "${indentation}${tab}$tab$tab(\"$array[2]\", \"$array[3]\"),\n";
                print $fh_testcases "${indentation}${tab}$tab$tab(\"$array[0]\", \"$array[1]\"),\n";

                print $fh_testcases "${indentation}${tab}\{'$intent_json_result': [[\n";
                print $fh_testcases "${indentation}${tab}$tab$tab(\"$array[4]\", \"$array[5]\"),\n";
                print $fh_testcases "${indentation}${tab}$tab$tab(\"$array[0]\", \"$array[1]\"),\n";                    
                print $fh_testcases "${indentation}${tab}$tab$tab(\"$array[2]\", \"$array[3]\"),\n";

                print $fh_testcases "${indentation}${tab}\{'$intent_json_result': [[\n";
                print $fh_testcases "${indentation}${tab}$tab$tab(\"$array[2]\", \"$array[3]\"),\n";
                print $fh_testcases "${indentation}${tab}$tab$tab(\"$array[4]\", \"$array[5]\"),\n";
                print $fh_testcases "${indentation}${tab}$tab$tab(\"$array[0]\", \"$array[1]\"),\n"; 

                print $fh_testcases "${indentation}${tab}\{'$intent_json_result': [[\n";
                print $fh_testcases "${indentation}${tab}$tab$tab(\"$array[2]\", \"$array[3]\"),\n";
                print $fh_testcases "${indentation}${tab}$tab$tab(\"$array[0]\", \"$array[1]\"),\n";
                print $fh_testcases "${indentation}${tab}$tab$tab(\"$array[4]\", \"$array[5]\"),\n";

                print $fh_testcases "${indentation}${tab}\{'$intent_json_result': [[\n";
                print $fh_testcases "${indentation}${tab}$tab$tab(\"$array[0]\", \"$array[1]\"),\n";
                print $fh_testcases "${indentation}${tab}$tab$tab(\"$array[4]\", \"$array[5]\"),\n";
                print $fh_testcases "${indentation}${tab}$tab$tab(\"$array[2]\", \"$array[3]\"),\n";
            }

```