{
    "mode": "perldoc",
    "parameter": "Algorithm::DiffOld",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Algorithm%3A%3ADiffOld/json",
    "generated": "2026-06-12T20:46:04Z",
    "synopsis": "use Algorithm::DiffOld qw(diff LCS traversesequences);\n@lcs    = LCS( \\@seq1, \\@seq2, $comparisonfunction );\n$lcsref = LCS( \\@seq1, \\@seq2, $comparisonfunction );\n@diffs = diff( \\@seq1, \\@seq2, $comparisonfunction );\ntraversesequences( \\@seq1, \\@seq2,\n{ MATCH => $callback,\nDISCARDA => $callback,\nDISCARDB => $callback,\n},\n$comparisonfunction );",
    "sections": {
        "NAME": {
            "content": "Algorithm::DiffOld - Compute `intelligent' differences between two files / lists but use the old\n(<=0.59) interface.\n",
            "subsections": []
        },
        "NOTE": {
            "content": "This has been provided as part of the Algorithm::Diff package by Ned Konz. This particular\nmodule is ONLY for people who HAVE to have the old interface, which uses a comparison function\nrather than a key generating function.\n\nBecause each of the lines in one array have to be compared with each of the lines in the other\narray, this does M*N comparisons. This can be very slow. I clocked it at taking 18 times as long\nas the stock version of Algorithm::Diff for a 4000-line file. It will get worse quadratically as\narray sizes increase.\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Algorithm::DiffOld qw(diff LCS traversesequences);\n\n@lcs    = LCS( \\@seq1, \\@seq2, $comparisonfunction );\n\n$lcsref = LCS( \\@seq1, \\@seq2, $comparisonfunction );\n\n@diffs = diff( \\@seq1, \\@seq2, $comparisonfunction );\n\ntraversesequences( \\@seq1, \\@seq2,\n{ MATCH => $callback,\nDISCARDA => $callback,\nDISCARDB => $callback,\n},\n$comparisonfunction );\n",
            "subsections": []
        },
        "COMPARISON FUNCTIONS": {
            "content": "Each of the main routines should be passed a comparison function. If you aren't passing one in,\nuse Algorithm::Diff instead.\n\nThese functions should return a true value when two items should compare as equal.\n\nFor instance,\n\n@lcs    = LCS( \\@seq1, \\@seq2, sub { my ($a, $b) = @; $a eq $b } );\n\nbut if that is all you're doing with your comparison function, just use Algorithm::Diff and let\nit do this (this is its default).\n\nOr:\n\nsub someFunkyComparisonFunction\n{\nmy ($a, $b) = @;\n$a =~ m{$b};\n}\n\n@diffs = diff( \\@lines, \\@patterns, \\&someFunkyComparisonFunction );\n\nwhich would allow you to diff an array @lines which consists of text lines with an array\n@patterns which consists of regular expressions.\n\nThis is actually the reason I wrote this version -- there is no way to do this with a key\ngeneration function as in the stock Algorithm::Diff.\n",
            "subsections": []
        }
    },
    "summary": "Algorithm::DiffOld - Compute `intelligent' differences between two files / lists but use the old (<=0.59) interface.",
    "flags": [],
    "examples": [],
    "see_also": []
}