in reply to string manipulations with regular expressions

This seems to do what you want.

use strict; use warnings; my $str = "'abc', 'dec'f', ''ghc''"; print qq{$str\n}; $str = join q{ }, map {s{(?<!\A)'(?!\z)}{\\'}g; $_} split m{\s*,\s*}, $str; print qq{$str\n};

Output is

'abc', 'dec'f', ''ghc'' 'abc' 'dec\'f' '\'ghc\''

Cheers,

JohnGG