Algorithm-Diff-Any
view release on metacpan or search on metacpan
lib/Algorithm/Diff/Any.pm view on Meta::CPAN
use Algorithm::Diff;
my $diff = Algorithm::Diff->new();
=head1 COMPATIBILITY
This module was tested under Perl 5.10.1, using Debian Linux. However, because
it's Pure Perl and doesn't do anything too obscure, it should be compatible
with any version of Perl that supports its prerequisite modules.
If you encounter any problems on a different version or architecture, please
contact the maintainer.
=head1 EXPORTABLE FUNCTIONS
The following functions are available for import into your namespace:
=over
=item * prepare
=item * LCS
=item * LCSidx
=item * LCS_length
=item * diff
=item * sdiff
=item * compact_diff
=item * traverse_sequences
=item * traverse_balanced
=back
For full documentation, see the relevant functional descriptions in the Pure
Perl implementation, L<Algorithm::Diff>.
=cut
=head1 METHODS
=head2 new
Algorithm::Diff::Any->new( \@seq1, \@seq2, \%opts );
Creates a C<Algorithm::Diff::Any> object, based upon either the optimized
C/XS version of the algorithm, L<Algorithm::Diff::XS>, or falls back to
the Pure Perl implementation, L<Algorithm::Diff>.
Example code:
my $diff = Algorithm::Diff::Any->new( \@seq1, \@seq2 );
# or with options
my $diff = Algorithm::Diff::Any->new( \@seq1, \@seq2, \%opts );
This method will return an appropriate B<Algorithm::Diff::Any> object or
throw an exception on error.
=cut
# Wrappers around the actual methods
sub new {
my ($class, $seq1, $seq2, $opts) = @_;
Carp::croak('You must call this as a class method') if ref($class);
Carp::croak('You must provide two sequences to compare as array refs')
unless (ref($seq1) eq 'ARRAY' && ref($seq2) eq 'ARRAY');
my $self = {
};
if ($DRIVER eq 'XS') {
$self->{backend} = Algorithm::Diff::XS->new($seq1, $seq2, $opts);
}
else {
$self->{backend} = Algorithm::Diff->new($seq1, $seq2, $opts);
}
bless($self, $class);
return $self;
}
=head2 Next
$diff->Next( $count )
See L<Algorithm::Diff> for method documentation.
=cut
sub Next {
shift->{backend}->Next(@_);
}
=head2 Prev
$diff->Prev( $count )
See L<Algorithm::Diff> for method documentation.
=cut
sub Prev {
shift->{backend}->Prev(@_);
}
=head2 Reset
$diff->Reset( $pos )
See L<Algorithm::Diff> for method documentation.
=cut
sub Reset {
my $self = shift;
( run in 4.661 seconds using v1.01-cache-2.11-cpan-796a6f069b2 )