Hi i have an array for example (2,2,2,2,3,3,4,4,4,1,1,1) i want to convert it into this (2_2_2_2, 3_3 ,4_4_4, 1_1_1) by using join and then get back the original one by using split on every element of array. The code that i write is giving some error. Can you plz help me what i am doing wrong?

Thanks. But for getting @array= (2,2,2,2,3,3,4,4,4,1,1,1) back from @new_array={2_2_2_2 3_3 4_4_4 1_1_1} I need to use split function on every element of array and it shows the same result instead of spliting into original.

But it only works when we already know the exact length and order of elements of array and pass it as a string. I want to keep it generic. Like we have @new_array as an input with data elements like 2_2_2,3_3 etc. and we pass it to split function to get it like {2,2,2,3,3} .

This thread is actually a follow-up on one or possibly two previous threads in which the OP asked for a way to generate all permutations of the original data, but avoiding duplicates or equivalent values. This idea was to first join equivalent values into single scalars to create a much smaller array, generate the permutations on that smaller array, and then split the data again, so as to avoid generating a huge number of useless permutations and then filter out 99% of them. Although I don't remember all the details, I do not think a repeated sequence was possible.