Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
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; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl Log file error
by suhailck (Friar) on Dec 09, 2010 at 01:49 UTC | |
|
Re: Perl Log file error
by samarzone (Pilgrim) on Dec 09, 2010 at 07:03 UTC |