a sample from one of the data files is as follows:#!/usr/bin/perl use strict; open (FILE, "exp.log") || die; my @array = <FILE>; close(FILE); print "\n\n\nExpected log read and stored"; open (FILE2, "actual.log") || die; my @array2 = <FILE2>; close(FILE2); print "\n\n\nActual log read and stored\n\n\n"; my @sorted = sort(@array); my @sorted2 = sort(@array2); if(@sorted eq @sorted2) { print "Success! Actual log and expected log contain the same data\ +n\n";} else { print "Failure! Actual log and expected log contain different dat +a\n\n"; } #print "@sorted\n"; print "\n\n\n\n\n\n\n\n\n-------------------------------------\n\n\n\n +\n\n"; #print "@sorted2\n"; exit;
The idea I had was to read in the two files, sort them (thus making the out of order a non issue)then compare the newly sorted array. However the problem I'm having is when i make subtle changes to one of the files (for eg changing a number from 20 to 19) the script still believes the two files are equal and only denotes a "failure" if the one of the text files has more lines introduced. Hope this makes sense. All the best!.MAMACACHE_REGRESSION.AGT.M Type: INITIAL Status OK MdMsgType | 1 | U8 | 1 MdMsgStatus | 2 | U8 | 0 MdSeqNum | 10 | U32 | 0 MamaAppMsgType | 18 | U8 | 0 MamaSenderId | 20 | U64 |6991275514488954478 .MAMACACHE_REGRESSION.BCO.M Type: INITIAL Status OK MdMsgType | 1 | U8 | 1 MdMsgStatus | 2 | U8 | 0 MdSeqNum | 10 | U32 | 0 MamaAppMsgType | 18 | U8 | 0 MamaSenderId | 20 | U64 | 6991275514488954478
In reply to Comparing unordered but similar data files by gwam
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |