@fields = ("A", "B", "C", "D", "E", "F"); $splitem = join '\s*(\S*)\s*', map quotemeta $_, @fields; print $splitem; for my $rec (@accounts) { my @rowdata = $rec =~ /^$splitem\z/o or warn("misparsed $rec"), next; push @accounts_2, \@rowdata; } for ($j = 0; $j < @accounts_2; ++$j) { for ($i = 0; $i < @{$accounts_2[$j]}; ++$i) { print ("\$accounts_2[$j][$i] = $accounts_2[$j][$i]\n"); } }