1Algorithm::DiffOld(3) User Contributed Perl DocumentationAlgorithm::DiffOld(3)
2
3
4

NAME

6       Algorithm::DiffOld - Compute `intelligent' differences between two
7       files / lists but use the old (<=0.59) interface.
8

NOTE

10       This has been provided as part of the Algorithm::Diff package by Ned
11       Konz.  This particular module is ONLY for people who HAVE to have the
12       old interface, which uses a comparison function rather than a key
13       generating function.
14
15       Because each of the lines in one array have to be compared with each of
16       the lines in the other array, this does M*N comparisions. This can be
17       very slow. I clocked it at taking 18 times as long as the stock version
18       of Algorithm::Diff for a 4000-line file. It will get worse
19       quadratically as array sizes increase.
20

SYNOPSIS

22         use Algorithm::DiffOld qw(diff LCS traverse_sequences);
23
24         @lcs    = LCS( \@seq1, \@seq2, $comparison_function );
25
26         $lcsref = LCS( \@seq1, \@seq2, $comparison_function );
27
28         @diffs = diff( \@seq1, \@seq2, $comparison_function );
29
30         traverse_sequences( \@seq1, \@seq2,
31                            { MATCH => $callback,
32                              DISCARD_A => $callback,
33                              DISCARD_B => $callback,
34                            },
35                            $comparison_function );
36

COMPARISON FUNCTIONS

38       Each of the main routines should be passed a comparison function. If
39       you aren't passing one in, use Algorithm::Diff instead.
40
41       These functions should return a true value when two items should
42       compare as equal.
43
44       For instance,
45
46         @lcs    = LCS( \@seq1, \@seq2, sub { my ($a, $b) = @_; $a eq $b } );
47
48       but if that is all you're doing with your comparison function, just use
49       Algorithm::Diff and let it do this (this is its default).
50
51       Or:
52
53         sub someFunkyComparisonFunction
54         {
55               my ($a, $b) = @_;
56               $a =~ m{$b};
57         }
58
59         @diffs = diff( \@lines, \@patterns, \&someFunkyComparisonFunction );
60
61       which would allow you to diff an array @lines which consists of text
62       lines with an array @patterns which consists of regular expressions.
63
64       This is actually the reason I wrote this version -- there is no way to
65       do this with a key generation function as in the stock Algorithm::Diff.
66
67
68
69perl v5.12.0                      2006-07-31             Algorithm::DiffOld(3)
Impressum