Suppose I have 2 arrays like mentioned below
@a1 = ("Vinay", Raj, harry);
@b1 = ("dude","rock");
After merging I want to have result like this
[
Vinay
dude
Vinay
rock
Raj
dude
Raj
rock
harry
dude
harry
rock
]
basically I want to merge the each index values of array1 to all the index values of array2.
Adding to the above question I have another query.
For the same question above how to merge 2 arrays at particular array index. For example I have 2 arrays of each 160 elements, now I want to merge array at every 5th element in sets, is that possible?
Here is one way to do it. May not be the best perl syntax, though. The double for loop means you will be pushing every combination of the two arrays into the merged array. I’ve tried to set it up so that the result is in the order you specified in the question.