while () { chomp; my ($pref,$data) = (/^((?:[^,]*,){3})(.*)/); print OUTPUT "$pref$_\n" for split /,/, $data; }