in reply to Super Diff?
Algorithm::Diff useage for difflike output looks something like:
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.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; }
-Daniel
Edit: 2001-03-03 by neshura
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Super Diff?
by daniell (Sexton) on Feb 13, 2001 at 00:17 UTC |