I have to compare details line by line in two log files having certain keyword "mti_clk_chk". Till now I'm able to parse it line by line with required keyword from both files into a third file. Now I want to compare the data present after the keyword following colon(:) and in output file I have to print the mismatched lines from first data-set on comparing it with second data-set and number of lines in second data set that are not present in first data-set. Data after parsing two log files is given below. Please help me out how to compare details provided in each line between two set of data.
open(FILE, "<x.log"); my @array = <FILE>; close(FILE); open(FILE, "<y.log"); my @array1 = <FILE>; close(FILE); open(FILE, ">>file.txt"); my @array2 = <FILE>; foreach $_ (@array & @array1) { @array2 = grep {$_ =~ "mti_clk_chk:"} (@array); print FILE "@array2"; print FILE "\n \n \n"; # close(FILE); @array2 = grep {$_ =~ "mti_clk_chk:"} (@array1); print FILE "@array2"; close(FILE); exit; }
Sample data in file.txt after parsing two input logs (x.log and y.log) ******************************************
INFO @576892 mti_clk_chk: run_stimulus called; T=576892 INFO @1102266 PHResourceLayer_Z4: mti_clk_chk:################ start o +f test ################ ; T=1102266 INFO @1102334 PHResourceLayer_Z4: mti_clk_chk:Checking the period of M +TI, MTI10 clk from SV; T=1102334 INFO @1102372 mti_clk_chk: Checking period of MTI CLk; T=1102372 INFO @1102377 mti_clk_chk: Period value of MTI Clock: 3.125000 ns; T=1 +102377 INFO @1102377 mti_clk_chk: MTI Clock is being generated correctly ; T= +1102377 INFO @1102377 mti_clk_chk: Checking period of MTI10 CLk; T=1102377 INFO @1102418 mti_clk_chk: Period value of MTI10 Clock: 31.250000 ns; +T=1102418 INFO @1102418 mti_clk_chk: MTI10 Clock is being generated correctly ; +T=1102418 INFO @1102717 PHResourceLayer_Z4: mti_clk_chk: All clock period Checki +ng done; T=1102717 INFO @1148661 mti_clk_chk: C-Code exit execution. code=<aa>; T=1148661 INFO @1148661 mti_clk_chk: ************************ SV END*********** +********* ; T=1148661 UVM_INFO @0 reporter [testbench.top_level_module.\mti_clk_chk::main ]: + MTI_CLK_CHK_STIM Started .....; T=0 UVM_INFO @0 reporter [testbench.top_level_module.\mti_clk_chk::main ]: + run_stimulus called; T=0 UVM_INFO @1092507 reporter [Z4_COREA]: mti_clk_chk: ################ s +tart of test ################ ; T=1092507 UVM_INFO @1092563 reporter [Z4_COREA]: mti_clk_chk: Checking the perio +d of MTI, MTI10 clk from SV; T=1092563 UVM_INFO @1092598 reporter [testbench.top_level_module.\mti_clk_chk::m +ain ]: Checking period of MTI CLk; T=1092598 UVM_INFO @1092605 /proj/rru2_verif/usr/Tilak/SV_UVM/testbench/data_ipd +ss/v_ms_mti_stim_vip/testbench/classes_v/mti_clk_chk.sv(147) uvm_test +_top.default_env.default_sequencer[100]@@mti_clk_chk [mti_clk_chk:INF +O]: Period value of MTI Clock: 3.125000 ns; T=1092605 UVM_INFO @1092605 reporter [testbench.top_level_module.\mti_clk_chk::m +ain ]: MTI Clock is being generated correctly ; T=1092605 UVM_INFO @1092605 reporter [testbench.top_level_module.\mti_clk_chk::m +ain ]: Checking period of MTI10 CLk; T=1092605 UVM_INFO @1092655 /proj/rru2_verif/usr/Tilak/SV_UVM/testbench/data_ipd +ss/v_ms_mti_stim_vip/testbench/classes_v/mti_clk_chk.sv(165) uvm_test +_top.default_env.default_sequencer[100]@@mti_clk_chk [mti_clk_chk:INF +O]: Period value of MTI10 Clock: 31.250000 ns; T=1092655 UVM_INFO @1092655 reporter [testbench.top_level_module.\mti_clk_chk::m +ain ]: MTI10 Clock is being generated correctly ; T=1092655 UVM_INFO @1092850 reporter [Z4_COREA]: mti_clk_chk: All clock period +Checking done; T=1092850 UVM_INFO @1092886 /proj/rru2_verif/usr/Tilak/SV_UVM/testbench/data_ipd +ss/v_ms_mti_stim_vip/testbench/classes_v/mti_clk_chk.sv(186) uvm_test +_top.default_env.default_sequencer[100]@@mti_clk_chk [mti_clk_chk:INF +O]: ************************ SV END******************** ; T=1092886

In reply to 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.