Algorithm-Diff

 view release on metacpan or  search on metacpan

lib/Algorithm/Diff.pm  view on Meta::CPAN

    {                        # prepared hash must be in $b
        my $tmp = $b;
        $b = $a;
        $a = $tmp;
    }

    # Check for bogus (non-ref) argument values
    if ( !ref($a) || !ref($b) )
    {
        my @callerInfo = caller(1);
        die 'error: must pass array or hash references to ' . $callerInfo[3];
    }

    # set up code refs
    # Note that these are optimized.
    if ( !defined($keyGen) )    # optimize for strings
    {
        $keyGen = sub { $_[0] };
        $compare = sub { my ( $a, $b ) = @_; $a eq $b };
    }
    else

lib/Algorithm/Diff.pm  view on Meta::CPAN

    /^(range[12]|same|diff|base)$/i

The 1 or 2 after a name says which sequence you want the information
for (and where allowed, it is required).  The optional number before
"min" or "max" is the base to use.  So the following equalities hold:

    $diff->Get('min1') == $diff->Min(1)
    $diff->Get('0min2') == $diff->Min(2,0)

Using C<Get> in a scalar context when you've passed in more than one
name is a fatal error (C<die> is called).

=back

=head2 C<prepare>

Given a reference to a list of items, C<prepare> returns a reference
to a hash which can be used when comparing this sequence to other
sequences with C<LCS> or C<LCS_length>.

    $prep = prepare( \@seq1 );



( run in 0.228 second using v1.01-cache-2.11-cpan-65fba6d93b7 )