NAME

Data::Diff - data structure comparison module

SYNOPSIS

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();

DESCRIPTION

Data::Diff computes the differences between two abirtray complex data structures.

METHODS

Creation

new Data::Diff( $a, $b, $options )

Creates and retruns a new Data::Diff object with the differences between $a and $b.

Access

apply( $options )

Returns the result of applying one side over the other.

raw()

Returns the internal data structure that describes the differences at all levels within.

Functions

Diff( $a, $b, $options )

Compares the two arguments $a and $b and returns the raw comparison between the two.

EXPORT

Nothing by default but you can choose to export the non-OO function Diff().

NOTES

Difference Description Structure

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.

BUGS

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.

AUTHOR

George Campbell, <gilko@gilko.com>

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.

SEE ALSO

perl.