Array::Diff
Find the differences between two arrays
- Provided by: libarray-diff-perl (Version: 0.07-2)
- Report a bug
Find the differences between two arrays
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' ];
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.
This method may be invoked as an object method, in which case it will recalculate the differences and repopulate the "count", "added", and "removed" properties, or as a static method, in which case it will return a newly-created "Array::Diff" object with the properies set appropriately.
Algorithm::Diff
Daisuke Murase <typester@cpan.org>
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 LICENSE file included with this module.