$i=0; $line = join '', grep { $i++ % 2 ? {s/,/ /g} : 1} split /"/,$line; #### while() { print; $i = 0; print join '', grep { $i++ % 2 ? {s/,/ /g} : 1} split /"/; print "\n"; } __DATA__ one,two,three one,"two,three,five",four "one,two",three one,two,"three," #### one,two,three one,two,three one,"two,three,five",four one,two three five,four "one,two",three one two,three one,two,"three," one,two,three