sub diffy {
my $output;
my @one = split(/\n/, $_[0]);
my @two = split(/\n/, $_[1]);
my $equ = $_[2] || "==";
my $sub = $_[3] || "--";
my $add = $_[4] || "++";
my $eqX = $_[5] || "";
my $suX = $_[6] || "";
my $adX = $_[7] || "";
use Algorithm::Diff qw(traverse_sequences);
traverse_sequences(\@one, \@two, {
MATCH => sub { $output .= "$equ$one[shift]$eqX\n"},
DISCARD_A => sub { $output .= "$sub$one[shift]$suX\n"},
DISCARD_B => sub { $output .= "$add$two[shift,shift]$adX\n"},
});
return $output;
}
Which is sorta odd looking, but now that you have that code, you
don't really have to think about it. Here you can pass in $one and $two
as variables holding multi-line input, and optionally pass in
start tags for matching lines, deleted lines, and added lines, as well as
the end tags for the same.
-Daniel
Edit: 2001-03-03 by neshura | [reply] [d/l] [select] |
Why doesn't Algorithm::Diff seem relevant?
It sounds like what you're looking for is a wrapper
that selects the specific files based on the supplied
date range (easy enough),
and then loops through the file list
applying Algorithm::Diff
to do the heavy lifting and print the differences.
| [reply] [d/l] [select] |
I suspect that you are going to be inventing at least a few
spokes on that wheel. Step one is quite doable with File::Find
which should be already installed with Perl.
Step 2 is all you. You should decide how to parse the files
and compare them. Do you really need a full file diff?
If so you may just consider jobbing it out to the unix
diff. If you are just looking for one or two specific things
I'd recommend parsing it a little more manually than diff.
Sorry I can't help more than that but it is a weird
thing by the description.
--
$you = new YOU;
honk() if $you->love(perl) | [reply] |
It is weird. The frustrating part is that the reason I can't do:
foreach my $file(@list_of_files_to_compare_to_start_date_file){
if ($file_a != $file) {
print "$file\n";
}
}
is that I need to build in logic for brain-dead people that are responsible for certain naming-conventions contained in these files. Because of this, the above could incorrectly report a not-equalling b, based upon my definition of "equals" | [reply] [d/l] |