my @fields; ... foreach my $row (@data) { @string = split(/ +/); for (0..$#string) { push @{ $fields[$_] }, $string[$_]; } } ...