Help for this page
open(my $fh, '>:utf8', 'out.xml') || die "Failed to open file"; print $fh $str; close($fh) || die "Failed to close file";
use XML::DOM; use open OUT => ':utf8'; use open ':std'; # as before... print $str;