Manual Reference Pages - ARRAY::DIFF (3)
Array::Diff - 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. Its a simple wrapper around Algorithm::Diff.
And if you need more complex array tools, check Array::Compare.
Create a new Array::Diff object.
diff ( OLD, NEW )
Compute the differences between two arrays. The results are stored
in the added, deleted, and count 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 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
added ( [VALUES ] )
Get or set the elements present in the NEW array and absent in
the OLD one at the comparison performed by the last diff()
deleted ( [VALUES] )
Get or set the elements present in the OLD array and absent in
the NEW one at the comparison performed by the last diff()
count ( [VALUE] )
Get or set the total number of added or deleted elements at
the comparison performed by the last diff() invocation.
This count should be equal to the sum of the number of elements in
the added and deleted properties.
Daisuke Murase <email@example.com>
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
LICENSE file included with this module.
|perl v5.20.3 ||ARRAY::DIFF (3) ||2010-10-08 |
Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.