tags:

views:

121

answers:

2

Hi dear Friends.... i am new to perl environment....i have n number of arrays with n number of strings in it and iam trying to get the combinations of all the strings of all the arrays ie i have like.....

array1="array1_String_1,array1_String_2,array1_String_3 ..... array1_String_n"; array2="array2_String_1,array2_String_2,array2_String_3 ..... array2_String_n"; array3="array3_String_1,array3_String_2,array3_String_3 ..... array3_String_n";
.
.
.
.
arrayn="arrayn_String_1,arrayn_String_2,arrayn_String_3 ..... arrayn_String_n;

example suppose if i take " array1_String_1 " it has to get the combinations from array2,array3.....arrayn but not from array1.

Similarly "array2_String_1" has to get combinations from all the arrays except array2 likewise it has to cover all the combinations of strings except the array which that string is stored. Like that i need to get combinations of all the strings in an array with other other arrays.

It should not go for combinations of the strings that are in the same array.ie array1 elements has to get combinations from array2,array3.... arrayn but not from array1

How can i get the combinations of all the strings of all the arrays in perl.... please help me... Please

+7  A: 

Check out the Math::Combinatorics and Algorithm::Combinatorics modules.

Ether
Thanks a lot Sir... is that possible without those modules? can you give me some examples please
jack
@jack: of course it's possible without those modules (it's just code, after all) -- may I ask why you don't want to use modules? You can look at the source code to see how the algorithms are implemented, to give ideas for your own code.
Ether
+1  A: 

I use my Set::CrossProduct module to do this sort of thing.

brian d foy