If you need to store the data in a new array (I'll assume an array of arrays), you could do this (reusing the data kindly provided by Lennotoecom):
my @table = ('a b c d e', 'f g h i j', 'k l m n o', 'p q r s t', 'u
+v w x y');
my @table2 = map { [(split / /, $_)[1, 4]] } @table;
The @table2 array now looks like this:
0 ARRAY(0x803cc6d8)
0 ARRAY(0x8042f630)
0 'b'
1 'e'
1 ARRAY(0x8042f828)
0 'g'
1 'j'
2 ARRAY(0x8042f840)
0 'l'
1 'o'
3 ARRAY(0x8042f540)
0 'q'
1 't'
4 ARRAY(0x8042f870)
0 'v'
1 'y'
If you want an array of lines, changing the second line to:
my @table2 = map { join " ", (split / /, $_)[1, 4] } @table;
And the resulting array is now:
0 'b e'
1 'g j'
2 'l o'
3 'q t'
4 'v y'
Edit: I did not look at it very carefully at the time, but I see now that the second solution I suggested just above is almost the same as the one suggested by Lennotoecom. Sorry for repeating almost the same thing, although this was not intentional.
|