my @cols; for my $row (@array) { my $i = 0; push @{$cols[$i++]}, $i % 2 ? $_ : $b[$_] for split /,/, $row; }