#!/usr/bin/perl -w use strict; use warnings; use XML::Simple; use Text::CSV_XS; #open DIPFILE, ">> C:/director/DIPFILE.TXT"; #open LOGFILE, ">> C:/director/DIPLOG.LOG"; #Pull in all the xml files for each report. my @dipfile = glob('C:/director/*.xml'); my $csv = Text::CSV_XS->new({always_quote => 0}); foreach my $xml_file (@dipfile) { my $ref = XML::Simple::XMLin($xml_file, SuppressEmpty => ''); my ($fileName) = "//prime/ReportExtract/Director/" . $ref->{fileName}; my ($default_name) = $ref->{defaultName}; my ($doc_type) = '1'; #Default set to unidentified Document Type. my ($default_description) = $ref->{defaultDescription}; my ($report_time) = $ref->{reportExecutionTime}; my ($reportSearchPath) = $ref->{reportSearchPath}; if (substr($reportSearchPath,23,10) eq "Operations"){$doc_type = 1719}; $csv->combine($fileName,$doc_type, $default_name,$default_description,$report_time); print $csv->string, "\n"; }