my @filelist = (-f, <*.xml>); foreach my $file (@filelist) { print "Working on... $file\n"; my $twig = new XML::Twig(TwigRoots => {title => 1, text => 1}); $twig->parsefile($file); open(Output, ">:utf8", "2_$file") or die "can't open file $!\n"; $twig->root->print(\*Output); close (Output); }