Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

algorithm::diffold(3) [mojave man page]

Algorithm::DiffOld(3)					User Contributed Perl Documentation				     Algorithm::DiffOld(3)

NAME
Algorithm::DiffOld - Compute `intelligent' differences between two files / lists but use the old (<=0.59) interface. NOTE
This has been provided as part of the Algorithm::Diff package by Ned Konz. This particular module is ONLY for people who HAVE to have the old interface, which uses a comparison function rather than a key generating function. Because each of the lines in one array have to be compared with each of the lines in the other array, this does M*N comparisions. This can be very slow. I clocked it at taking 18 times as long as the stock version of Algorithm::Diff for a 4000-line file. It will get worse quadratically as array sizes increase. SYNOPSIS
use Algorithm::DiffOld qw(diff LCS traverse_sequences); @lcs = LCS( @seq1, @seq2, $comparison_function ); $lcsref = LCS( @seq1, @seq2, $comparison_function ); @diffs = diff( @seq1, @seq2, $comparison_function ); traverse_sequences( @seq1, @seq2, { MATCH => $callback, DISCARD_A => $callback, DISCARD_B => $callback, }, $comparison_function ); COMPARISON FUNCTIONS
Each of the main routines should be passed a comparison function. If you aren't passing one in, use Algorithm::Diff instead. These functions should return a true value when two items should compare as equal. For instance, @lcs = LCS( @seq1, @seq2, sub { my ($a, $b) = @_; $a eq $b } ); but if that is all you're doing with your comparison function, just use Algorithm::Diff and let it do this (this is its default). Or: sub someFunkyComparisonFunction { my ($a, $b) = @_; $a =~ m{$b}; } @diffs = diff( @lines, @patterns, &someFunkyComparisonFunction ); which would allow you to diff an array @lines which consists of text lines with an array @patterns which consists of regular expressions. This is actually the reason I wrote this version -- there is no way to do this with a key generation function as in the stock Algorithm::Diff. perl v5.18.2 2006-07-30 Algorithm::DiffOld(3)

Check Out this Related Man Page

Algorithm::Diff::XS(3pm)				User Contributed Perl Documentation				  Algorithm::Diff::XS(3pm)

NAME
Algorithm::Diff::XS - Algorithm::Diff with XS core loop SYNOPSIS
# Drop-in replacement to Algorithm::Diff, but "compact_diff" # and C<LCSidx> will run much faster for large data sets. use Algorithm::Diff::XS qw( compact_diff LCSidx ); DESCRIPTION
This module is a simple re-packaging of Joe Schaefer's excellent but not very well-known Algorithm::LCS with a drop-in interface that simply re-uses the installed version of the Algorithm::Diff module. Note that only the "LCSidx" function is optimized in XS at the moment, which means only "compact_diff" will get significantly faster for large data sets, while "diff" and "sdiff" will run in identical speed as "Algorithm::Diff". BENCHMARK
Rate Algorithm::Diff Algorithm::Diff::XS Algorithm::Diff 14.7/s -- -98% Algorithm::Diff::XS 806/s 5402% -- The benchmarking script is as below: my @data = ([qw/a b d/ x 50], [qw/b a d c/ x 50]); cmpthese( 500, { 'Algorithm::Diff' => sub { Algorithm::Diff::compact_diff(@data) }, 'Algorithm::Diff::XS' => sub { Algorithm::Diff::XS::compact_diff(@data) }, }); SEE ALSO
Algorithm::Diff, Algorithm::LCS. AUTHORS
Audrey Tang <cpan@audreyt.org> COPYRIGHT
Copyright 2008 by Audrey Tang <cpan@audreyt.org>. Contains derived code copyrighted 2003 by Joe Schaefer, <joe+cpan@sunstarsys.com>. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2008-10-24 Algorithm::Diff::XS(3pm)
Man Page