use strict;
my $str = '“Full Quote” The Left Quote is Missing”
';
my $regex = qr/(?x) # Free-Spacing
(?(DEFINE) # Define a few subroutines
(?<double>“(?:(?!&[lr]squo;).)*”) # full set of doubles (no quotes inside)
(?<single>‘(?:(?!&[lr]dquo;).)*’) # full set of singles (no quotes inside)
(?<notquotes>(?:(?!&[lr][sd]quo;).)*) # chars that are not quotes
) # end DEFINE
^ # Start of string
( # Start group: balanced portion
(?: # Start non-capture group
(?¬quotes) # Any non-quote chars
&l(?<type>[sd])quo; # Opening quote, capture single or double type
# any full singles, doubles, not quotes or recursion
(?:(?&single)|(?&double)|(?¬quotes)|(?R))*
&r\k<type>quo; # Closing quote of the correct type
)*+ # Repeat non-capture group
) # end balanced portion
\K
(
(?¬quotes)
&r([sd])quo; # unmatched quote
)/p;
my $subst = '&l\\7quo;\\6';
my $result = $str =~ s/$regex/$subst/r;
print "The result of the substitution is' $result\n";
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Perl, please visit: http://perldoc.perl.org/perlre.html