Hi, In the below perl script when it is generating the log file. It is outputting the last error file name instead of all the error file names. Can anybody say where I am doing wrong.

#!/usr/local/bin/perl use strict; use warnings; use XML::Simple; use File::Basename; my @InputFiles = <'C:\\Documents and Settings\\user\\Desktop\\out\BATC +H*\\*\\*\\*.xml'>; my $xml = XML::Simple->new; foreach my $fileName(@InputFiles) { 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') { my $dir = 'C:\\Documents and Settings\\user\\Desktop\\out\\'.basen +ame($filename).".out"; $dir =~s/(.*)_.*/$1/i; mkdir $dir; my $OutputFile = "$dir\\Fits_Summarylog.txt +"; open(my $OUTF, ">$OutputFile") or die "Can +'t open output file ($OutputFile): $!"; print $OUTF "$filename | Identity Format Error\n"; next; } if ($file->{filestatus}{'well-formed'}{'content'} ne 'true') { my $dir = 'C:\\Documents and Settings\\user\Desktop\\out\\'.basena +me($filename).".out"; $dir =~s/(.*)_.*/$1/i; mkdir $dir; my $OutputFile = "$dir\\Fits_Summarylog +.txt"; open(my $OUTF, ">$OutputFile") or die +"Can't open output file ($OutputFile): $!"; print OUTF " $filename | well formed Error\n"; next; } if ($file->{filestatus}{'valid'}{'content'} ne 'true') { my $dir = 'C:\\Documents and Settings\\user\\Desktop\\out\\'.basen +ame($filename).".out"; $dir =~s/(.*)_.*/$1/i; mkdir $dir; my $OutputFile = "$dir\\Fits_Summarylog +.txt"; open(my $OUTF, ">$OutputFile") or die +"Can't open output file ($OutputFile): $!"; print OUTF " $filename | Valid Status Error\n"; next; } }

In reply to Perl Log file error 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.