$ perl -Mstrict -Mwarnings -E ' while (<>) { my ($start, $end) = /^(.+?)("[^"]+")$/; my @finals = split /,/ => substr $end, 1, -1; say $start, q{"}, shift(@finals), q{"}; say q{ } x length($start), q{"}, shift(@finals), q{"} while @finals; } ' fred.dat "A","B","C","D" "A","B","C","D" "E" "F" "A","B","C","D" "A","B","C","D" "R" "T"