in reply to Match a comma between two words

Here is something similar to what you are looking for. Perhaps this will help you work out your particular solution. (I have a similar situation, dealing with csv files and not having the very useful modules available to me.) This code replaces commas inside of quotation marks with spaces so I could subsequently use split.

$olds='one,two,"three,four,five","six",seven,"eight,nine"'; $i = 0; $news = join '', grep { $i++ % 2 ? {s/,/ /g} : 1 } split /"/,$olds; print $news . "\n";

Output:

one,two,three four five,six,seven,eight nine

Update

Original version would delete single word inside quotation marks.

1 Peter 4:10