SYNOPSIS

    my @old = ( 'a', 'b', 'c' );
    my @new = ( 'b', 'c', 'd' );

    my $diff = Array::Diff->diff( \@old, \@new );

    $diff->count   # 2
    $diff->added   # [ 'd' ];
    $diff->deleted # [ 'a' ];

DESCRIPTION

This module compares two arrays and returns the added or deleted elements in two separate arrays. It's a simple wrapper around Algorithm::Diff.

And if you need more complex array tools, check Array::Compare.

METHODS

new ()

Create a new \*(C`Array::Diff\*(C' object.

diff ( \s-1OLD\s0, \s-1NEW\s0 )

Compute the differences between two arrays. The results are stored in the \*(C`added\*(C', \*(C`deleted\*(C', and \*(C`count\*(C' properties that may be examined using the corresponding methods. This method may be invoked as an object method, in which case it will recalculate the differences and repopulate the \*(C`count\*(C', \*(C`added\*(C', and \*(C`removed\*(C' properties, or as a static method, in which case it will return a newly-created \*(C`Array::Diff\*(C' object with the properies set appropriately.

added ( [\s-1VALUES\s0 ] )

Get or set the elements present in the \*(C`NEW\*(C' array and absent in the \*(C`OLD\*(C' one at the comparison performed by the last \*(C`diff()\*(C' invocation.

deleted ( [\s-1VALUES\s0] )

Get or set the elements present in the \*(C`OLD\*(C' array and absent in the \*(C`NEW\*(C' one at the comparison performed by the last \*(C`diff()\*(C' invocation.

count ( [\s-1VALUE\s0] )

Get or set the total number of added or deleted elements at the comparison performed by the last \*(C`diff()\*(C' invocation. This count should be equal to the sum of the number of elements in the \*(C`added\*(C' and \*(C`deleted\*(C' properties.

RELATED TO Array::Diff…

Algorithm::Diff

AUTHOR

Daisuke Murase <[email protected]>

COPYRIGHT AND LICENSE

Copyright (c) 2009 by Daisuke Murase.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the \s-1LICENSE\s0 file included with this module.