Data::Diff - data structure comparison module
use Data::Diff qw(diff);
# simple procedural interface to raw difference output
$out = diff( $a, $b );
# OO usage
$diff = Data::Diff->new( $a, $b );
$new = $diff->apply();
$changes = $diff->diff_a();
Data::Diff computes the differences between two abirtray complex data structures.
Creates and retruns a new Data::Diff object with the differences between $a and $b.
Returns the result of applying one side over the other.
Returns the internal data structure that describes the differences at all levels within.
Compares the two arguments $a and $b and returns the raw comparison between the two.
Nothing by default but you can choose to export the non-OO function Diff().
The data structure returned by both the method raw and the function Diff. follow this same convention of metadata. The value returned is always a hash reference and the hash will have one or more of the following hash keys: type, same, diff, diff_a, diff_b, uniq_a and uniq_b.
The type key is just a scalar string that is the data type of the sub elements in metadata. The data type of the values, for the other keys, depend on the input values that were passed in via the $a and $b references. for example if $a and $b were both array references then all of the keys in the metadata structure will be array references. Recusively the elements in the array references for the diff key and the same key will also be of the same metadata structure. The values of the elements in the diff_a, diff_b, uniq_a and uniq_b will not have any metadata associated with them since they represent the orignal values from the input.
If you thought your structure of array and hash references was a mess just wait till this modules get ahold of it.
The Data::Diff does not have any way to detect a cycle in the references and will crash if there is a loop.
The module does its best to handle things like HANDLES and CODE and LVALUES but it might not do the best job because visiblity into those data types is poor.
George Campbell, <firstname.lastname@example.org>
Copyright (c) 1996-98 George Campbell. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Data::Diff, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.