in reply to Matching quote characters?

my $string = '"foo"'; $string =~ s/\"(.*?)\"?/$1/; print $string;
But the .*? always gobbles up the trailing "
Actually it doesn't. Your non-greedy .*? matches as few characters as possible: Zero. Then, one or zero " follows. You can see it from the following snippet:
my $string = '"foo"'; $string =~ s/"(.*?)"?/_$1_/; # note that you don't have to escape " print $string; # prints __foo"
For a solution to your problem, see the other posts.