Please continue to spend effort on your own code. Do not expect final polished code from this forum. My objective was to demo an approach that probably hadn't occurred to you. I believe that I was successful in that endeavour. The Monks do expect that you spend some serious effort trying to understand the advice that you have been given.
Update: Homework for the OP:
1) Open and read log file X, line by line and create a hash %X like I show as %A. Hashes have no order to them so we need an array to maintain the input order. Save each key to hash %X as a new element of an array (i.e push that key onto another array).
2) Open and read log file Y, line by line and create a hash %Y like I show as %B. There is no need for an array here.
3) Now loop over the array from step (1) and print stuff that is common between hash %X and %Y.
This is not what you need:
Better:open(FILE, "<x.log"); my @array = <FILE>; # no need to use memory that way # a lot of the input line will be # thrown away close(FILE);
open(FILE, "<", "x.log") or die "unable to open x.log $!"; while my $line (<FILE>) { ... process each $line... }
In reply to Re^3: Compare two log files line by line containing a keyword
by Marshall
in thread Compare two log files line by line containing a keyword
by rahu_6697
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |