Hello rahu_6697,

Based on your updated description something like that should work:

#!/usr/bin/perl use strict; use warnings; use IO::All; use Data::Dumper; use List::Compare; my @x = io('x.log')->chomp->slurp; my @x_start = grep /mti_clk_chk/, @x && grep /start of test/, @x; my @x_period = grep /mti_clk_chk/, @x && grep /Checking the period/, @ +x; print Dumper \@x_start; # print Dumper \@x_period; my @y = io('y.log')->chomp->slurp; my @y_start = grep /mti_clk_chk/, @x && grep /start of test/, @y; my @y_period = grep /mti_clk_chk/, @x && grep /Checking the period/, @ +y; print Dumper \@y_start; # print Dumper \@y_period; my $lcStart = List::Compare->new('-u', \@x_start, \@y_start); my @LorRonlyStart = $lcStart->get_symmetric_difference; print Dumper \@LorRonlyStart; io('start.log')->appendln(@LorRonlyStart); my $lcPeriod = List::Compare->new('-u', \@x_period, \@y_period); my @LorRonlyPeriod = $lcPeriod->get_symmetric_difference; print Dumper \@LorRonlyPeriod; io('period.log')->appendln(@LorRonlyPeriod);

But I am not really sure if this is what you want as from my point of view you are comparing wrong data. I mean the lines that you provide us as sample there are not the same not just by T=<TIME> but also as syntax. For example you are comparing:

INFO @1102266 PHResourceLayer_Z4: mti_clk_chk:################ start o +f test ################ ; T=1102266 UVM_INFO @1092507 reporter Z4_COREA: mti_clk_chk: ################ sta +rt of test ################ ; T=1092507

The lines they do not have the same "@1102266" and "@1092507" so how you are going to be sure you are comparing the correct lines?

On the sample of code that I provided you above I am grepping lines with two parameters (I assume this should be enough). The problem appears when you are going to compare the arrays. Based on your description the T=<TIME> can be different but from my point of view this is not enough, you might need to add more parameters to be sure you are comparing the correct lines.

If so update your answer so we can try to help you further.

Hope this helps, BR

Seeking for Perl wisdom...on the process of learning...not there...yet!

In reply to Re^3: Compare two log files line by line containing a keyword by thanos1983
in thread Compare two log files line by line containing a keyword by rahu_6697

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.