Hi,
As per my understanding from your post, that you need data from __DATA__ area 3..4 and 5..6 in separate array of each row. I have saved data as another array ref, you can do deref and you can take data from each array.
There could be more efficient way, other than this.
use strict; use warnings; use Data::Dumper; my @arr = <DATA>; chomp @arr; my (@Arry1,@Arry2); foreach(@arr) { my @arr1 = split(/\s+/,$_); push (@Arry1,[@arr1[3..4]]); push (@Arry2,[@arr1[5..6]]); } print Dumper \@Arry1; print Dumper \@Arry2; __DATA__ AX8 0.23 42.4 1 1 1 1 AX4 0.65 53.6 0.2 7.8 9.1 2.3 AX12 0.34 23.9 3.2 7.2 1.2 9.3
In reply to Re: How to store the output from foreach loop into variable/array without printing?
by vinoth.ree
in thread How to store the output from foreach loop into variable/array without printing?
by hellohello1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |