in reply to Re^2: diff of two strings
in thread diff of two strings
my @output; printDiff($#s1, $#s2); print join "\n", @output; sub printDiff { my ($i, $j) = @_; if ($i > 0 && $j > 0 and $s1[$i] eq $s2[$j]) { printDiff($i-1, $j-1); $output[0] .= " " . $s1[$i]; $output[1] .= " " . $s1[$i]; } else { if ($j > 0 && ($i == 0 || $M[$i][$j-1] >= $M[$i-1][$j] +)) { printDiff($i, $j-1); $output[1] .= " <" . $s2[$j] . ">"; } elsif ($i > 0 && ($j == 0 || $M[$i][$j-1] < $M[$i-1][$ +j])) { printDiff($i-1, $j); $output[0] .= " [" . $s1[$i] . "]"; } } }
Perlmonks is the best [perl] community Perlmonks is <one> <of> the best community <of> <perl> <users>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: diff of two strings
by flaviusm (Acolyte) on Jan 09, 2008 at 05:17 UTC | |
by lima1 (Curate) on Jan 09, 2008 at 08:40 UTC |