foreach my $file (@files) { eval('use XML::LibXML'); eval('use XML::LibXSLT'); my $oXslt = XML::LibXSLT->new(); my $oSource = XML::LibXML->load_xml(location => $file); my $oStylesheetDoc = XML::LibXML->load_xml(location => $cPath, no_cdata=>1); my $hXSLTDoc = $oXslt->parse_stylesheet($oStylesheetDoc); my $hOutput = $hXSLTDoc->transform($oSource); my $cFilecontent = $hXSLTDoc->output_as_bytes($hOutput); my $cConvertedFile = $file."_Converted.XML"; open(FH,">$cConvertedFile") or die "cannot open $cConvertedFile : $!\n"; print FH $cFilecontent; close(FH); }