use warnings;
use strict;
use XML::Twig;
my $twig = XML::Twig->new(
char_handler => sub {
my ($txt) = @_;
$txt =~ s/"(.*?)"/'$1'/g;
return $txt;
},
### Note: These are included for terminal ease.
### The problem still exists without them.
pretty_print => 'indented',
keep_encoding => 1,
);
$twig->parsestring(*DATA);
$twig->flush();
__DATA__
"A", "B—C", "D"
####
'A', "B—C', 'D"
####
'A', 'B—C', 'D'