$ perl -pe "s/\"([^'\`])/'\$1/g" This is "an example", but "`this not"'. This is 'an example', but "`this not"'.