| [reply] [Watch: Dir/Any] |
How about looping through each file. Comparing it with ones after it in the array. You can even load ones that were previously compared, so you get a structure containing what you want.
Example:
use strict;
use Data::Dumper;
use File::Compare;
my @files = qw( file0 file1 file2 );
my @results;
foreach my $i (0..$#files){
$results[$i] = [];
#Already compared these
foreach my $j(0..($i-1)){
$results[$i][$j] = $results[$j][$i];
}
#Same File
$results[$i][$i] = 1;
#New Comparisons
foreach my $j(($i+1)..$#files){
$results[$i][$j] = compare($files[$i],$files[$j]);
}
}
print Dumper \@results;
So $results[0][1] is the result of a comparison between files file0 and file1, and $results[0][2] is the result of a comparison between files file0 and file2. | [reply] [Watch: Dir/Any] [d/l] [select] |
that's close to what I am trying to do, but not exactly. Let me give you the example of what I want to achieve I have a parse script written that looks through a log file and then builds three seporate files from the output these files actually hold Bind transfer stats. Now what I would like to do is parse the three files and do like a sdiff on all three, but sdiff will only do two files. In the end I want to have a list of lines that do not exsist in all files and what file they are missing in. Does that make any sense??
| [reply] [Watch: Dir/Any] |
If you have a parse script writen already why the extra step of going to 3 files, why not inspect the data and output the real result in one step?
-Waswas
| [reply] [Watch: Dir/Any] |
Sounds like an interesting problem, but I still can't quite picture the data and the result you want. These questions might clear things up for me:
Are the lines guaranteed to be unique?
Does the order of the lines matter as it does in diff?
If I see a line "XYZ" in file 1 and "XYZ" in file 2, and "XYZ" in file 3, are these the same line no matter where they show up in the respective files?
How big are the files? Would it be feasible to load them all into memory at the same time?
Is it ok to sort the files before doing the comparison or does your output need to be in a specific order?
Pretend letters are lines. What should be the output if the following are the contents of the three files?
file 1: A B C D E G
file 2: B A D E G H
file 3: A B D E G I
--
Eric Hammond | [reply] [Watch: Dir/Any] [d/l] |