Hi, I have a Perl script which recursively reads .JPG files form directories and sub directories and process them by triggering an external application and generate a xml log file for each image and after that it is trying to reading these xml log files and check for certain errors . if error exists it generates the file name and type of error. In my below script the first part is working I mean it is reading image files and creating the log files but the second one reading these log files for errors is not working. Can I get help regarding this logic and the mistakes in the script. Newbie to Perl so tried to some extent but not knowing exactly how to combine these two logic.

use File::Find; use File::Path; use XML::Simple; use File::Basename; use strict; use warnings; use diagnostics; # Get the directory from the command line or use the default director +y $search = shift || '/home/files/Input_test1'; # Get an array of all subdirectories find sub { push @dirs, $File::Find::name if -d }, $search ; for $dir ( @dirs ) { # opendir $dh, $dir or do { warn "Cannot open '$dir' $!" ; next ; } +; opendir( DIR, "$dir" ) ; @files = grep( /\.jpg$/, readdir( DIR ) ) ; closedir( DIR ) ; (my $logdir = $dir)=~s|^\Q$search/\E||i; $logdir =~ s|/IMAGES$||i; $logdir = "/home/output/logs/$logdir/NEW"; mkdir $logdir; # Creating a log file with the same filename to generate the logs foreach $file ( @files ) { print "$dir/$file\n" ; $logfilename =$file; $logfilename =~s/\.jpg$/.xml/; print "$logdir/$logfilename"; @args = ("/usr/software/fits-0.4.2/fits.sh", "-i", "$dir/$file", +"/usr/software/fits-0.4.2/fits.sh", "-o", "$logdir/$logfilename"); system( @args ) == 0 or die "system @args failed: $?"; } my $outfile = "$logdir" open OUTF, "> $outfile" or die print " can't create logfile; $!"; my $xml = XML::Simple->new; foreach my $fileName ($logfilename) { my ($filename, $directories, $suffix) = fileparse($fileName); my $file = $xml->XMLin($fileName) or die "Failed for $fileName: $! \n"; my $format = $file->{identification}{'identity'}{'format'}; if ($format ne 'JPEG File Interchange Format') { print OUTF "$filename | Identity Format Error\n"; }

In reply to Help regarding a perl script by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.