in reply to XML::DOM encodes in latin1 instead of UTF-8

Give this a spin. I was kind of screwing around with the Path::Class stuff just to have fun (not exactly how I'd do a production script -- still this has better error checking than the original and XML::LibXML is really quite nice).

use strict; use warnings; use XML::LibXML; use Path::Class; my $parser = XML::LibXML->new(); my $srcdir = shift || die "Forgot to give the source dir.\n"; my $dstdir = Path::Class::Dir->new( shift || die "Forgot to give the d +estination dir.\n" ); my @files = map { Path::Class::File->new($_) } glob("$srcdir*\.xml"); for my $file ( @files ) { print $file, $/; my $doc = $parser->parse_file($file); my $new_file = Path::Class::File->new( $dstdir, $file->basename ); print -e $new_file ? "Overwriting $new_file from $file\n" : "Creating $new_file from $file\n"; $doc->toFile($new_file, 1); }