You understood the question correctly and your output is quite good also, but I'm facing this issue while run. One thing more I want this output in a separate output file, please change the code accordingly.
Can't locate Data/Dump.pm in @INC (@INC contains: /usr/local/lib64/per +l5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/per +l5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at script3.pl lin +e 4. BEGIN failed--compilation aborted at script3.pl line 4
Code I am trying to run is
#!/usr/bin/perl; use strict; use warnings; use Data::Dump qw(pp); open(FILE, "<x.log"); my @array = <FILE>; close(FILE); open(FILE, "<y.log"); my @array1 = <FILE>; close(FILE); my @array =<<'EOF' =~ m/(^.*\n)/mg; EOF my @array1 =<<'EOF2' =~ m/(^.*\n)/mg; EOF2 @array = map{/^.*(mti_clk_chk:.*\n)/;$1;}@array; @array1 = map{/^.*(mti_clk_chk:.*\n)/;$1;}@array1; ## just print these arrays out so that we can see how to compare them? my $n=1; foreach (@array) {print "A$n) ",$_; $n++} print "===============================\n"; $n=1; foreach (@array1) {print "B$n) ",$_; $n++} ## Make hash tables of the 2 records ## regex could be better - not the point here.. just a quick demo of a +n approach.. my %A = map{/mti_clk_chk:(?::main :|INFO:)?\s*(.*).*\s*T=(\d+)$/;$1 => + $2}@array; my %B = map{/mti_clk_chk:(?::main :|INFO:)?\s*(.*).*\s*T=(\d+)$/;$1 => + $2}@array1; #print only common values in sequential order of file A print "\n********************************************\n"; print "Common Text descriptions with A and B T values:\n"; print "********************************************\n"; foreach my $mti (map{/mti_clk_chk:(?::main :|INFO:)?\s*(.*).*\s*T=(\d+ +)$/;$1}@array) { if (exists $B{$mti}) { print "$mti T(a)=$A{$mti} T(b)=$B{$mti}\n"; } }
In reply to Re^2: Compare two log files line by line containing a keyword
by rahu_6697
in thread Compare two log files line by line containing a keyword
by rahu_6697
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |