Algorithm::Diff is pretty good for producing diff like output
for two variables in Perl, but I would definitly just use:
`/usr/bin/diff $file[1] $file[2]` to get the diff of
files, its simpler. Also I'd suggest File::Find with a wanted
funciton that checks the date range in order to pick your files
Algorithm::Diff useage for difflike output looks something like:
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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.