I am reading the below log file and looking for the word error .If it finds error then it should print some stuff. But it is not printing when there is error.



LOG FILE:
QA-METS - Checksum log UID=61110530R Title=Lecture introductory to the course on anatomy, in the University + of Pennsylvania / FileID=BSE1 Filename=61110530R_000001.jpg METS: Mimetype=image/jpg Size=1950329 MD5=fb0ff0b498cb6ce79df20fdddd71 +da3f [Error] Checksum mismatch; Computed MD5=08141ce3c84cb54d57d40b502331 +2c53 FileID=BSE2 Filename=61110530R_000002.jpg METS: Mimetype=image/jpg Size=737596 MD5=7b44c390f7279a3f266652a96a5f6 +86d [Error] Checksum mismatch; Computed MD5=462db8d6b278f6fdb63f87fd2974 +e7e9 FileID=BSE3 Filename=61110530R_000003.jpg METS: Mimetype=image/jpg Size=1010181 MD5=8acd6e39a21f0fc18dfb6a54663f +a472 [Error] Checksum mismatch; Computed MD5=7e9c7959e3a3b60c4d2f80e089f0 +3f9d FileID=BSE4 Filename=61110530R_000004.jpg METS: Mimetype=image/jpg Size=655993 MD5=f655a572365bcea7c878201b7606d +68a [Error] Checksum mismatch; Computed MD5=0fbdfb7ba703e0ad810025135e4e +8070 FileID=BSE5 Filename=61110530R_000005.jpg METS: Mimetype=image/jpg Size=838116 MD5=2a055f3579db7f9c583c8cf84afdf +030 [Error] Checksum mismatch; Computed MD5=50a8ee3e882b79de5fe8a47be54c +c478 FileID=BSE6 Filename=61110530R_000006.jpg METS: Mimetype=image/jpg Size=511383 MD5=8dfa19092cdf0d76bf99eede88fae +e19 [Error] Checksum mismatch; Computed MD5=3380c9f79217ba0faee294ab9cff +db81 FileID=BSE7 Filename=61110530R_000007.jpg METS: Mimetype=image/jpg Size=881218 MD5=97d8a953cc1b8ab1dff728a8b0814 +6be [Error] Checksum mismatch; Computed MD5=37fa1505f9ca13251406658653af +4439 FileID=BSE8 Filename=61110530R_000008.jpg METS: Mimetype=image/jpg Size=496683 MD5=638a7f3cb7d2b189751c62c91e018 +d28 [Error] Checksum mismatch; Computed MD5=d008d5852cfaff6cf14fa0748b5d +044f

Current Script
#!/usr/local/bin/perl use strict; use warnings; use Data::Dumper; $/ = ""; my @InputFiles = (</usr/mlm/qa/logs/hhl/BATCH*/*/*_checksum.log>); foreach my $InputFile ( @InputFiles ) { print "$InputFile\n"; my %errors; open my $input_fh, '<', $InputFile or die "Can't open input file ($InputFile): $!"; my $uid = <$input_fh>; ($uid) = $uid =~ /UID=(\S+)/; while ( my $record = <$input_fh> ) { my ($md5) = $record =~ /METS:.+?MD5=(\S+)/; my ($filename) = $record =~ /Filename=(\S+)/; #my ($error) = $record =~ /[Error] +MD5=(\S+)/; my ($error) = $record =~ /\Q[Error]\E .+MD5=(\S+)/; if ( $error ) { $errors{$filename}{md5} = $md5; $errors{$filename}{computed} = $error; } } close $input_fh; my $count = keys %errors; foreach my $filename ( sort keys %errors ) { print join('|', $uid, $filename, $count, $errors{$filename}{md5}, $errors{$filename}{computed} ),"\n";

In reply to LOG FILE HELP IN PERL 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.