I have the following string A B C D E F G H I J
. I want to make an array out of it, so I use this
my @string = split/(\W)/, $text;
It works ok, and I get an array of 20 lines looking like this:
A
B
C
D
...
Now, I want to split this array in a given number of pieces (let's say 4 in this case), thus resulting I imagine in 4 smaller arrays of 5 lines each, looking like this @1 = A, ,B, ,C
, @2 = ,D, ,E,
, @3 = F, ,G, ,H
and @4 = ,I, ,J,
.
Finally, I want to interleave these 4 arrays in order to get an output array in which I first have the first line of each array, the the second line of each array, and so on... the final thing looking like this :
A
F
D
I
B
G
E
J
C
H
How to achieve this?