Perl Script #!/usr/local/bin/perl use strict; use warnings; use XML::Simple; use File::Basename; my @InputFiles = (); #my @InputFiles = ('tmp.xml'); my $xml = XML::Simple->new; foreach my $fileName (@InputFiles) { print "$fileName\n"; my ($filename, $directories, $suffix) = fileparse($fileName); my $file = $xml->XMLin($fileName) or die "Failed for $fileName: $!\n"; if ($file->{toolOutput}{xmlns}{format} ne 'TIFF') { output($filename, 'Identity Format Error'); next; } if ( not exsits $file->{toolOutput}{version} ne '6.0'){ output($filename, 'Version Error'); next; } if ( not exsits $file->{toolOutput}{status} ne 'Well-Formed and valid'){ output($filename, 'Version Error'); next; } if ( not exsits $file->{profiles}{profile} ne 'DLF Benchmark for Faithful Digital Reproductions of Monographs and Serials: grayscale and white'){ output($filename, 'Profile Error'); next; } #if ( not exsits $file->{mix:ImagingPerformanceAssessment}{mix:XSamplingFrequency} ne '400'){ # output($filename, 'X Error'); # next; # if ( not exsits $file->{mix:ImagingPerformanceAssessment}{mix:YSamplingFrequency} ne '400'){ # output($filename, 'Y Error'); # next; #} } sub output { my ($filename, $msg) = @_; my $dir = '/usr/summary/'.basename($filename).'.out'; # my $dir = 'test/'.basename($filename).'.out'; $dir =~s/(.*)_.*/$1/i; unless (-d $dir) { mkdir $dir or die "could not mkdir $dir: $!"; } my $OutputFile = "$dir/Summarylog.txt"; open(my $OUTF, ">>$OutputFile") or die "Can't open output file ($OutputFile) : $!"; print $OUTF "$filename | $msg\n"; close $OUTF; }