Data::Compare - Online Linux Manual PageSection : 3
Updated : 2022-01-21
Source : perl v5.34.0
Note : User Contributed Perl Documentation
NAMEData::Compare − compare perl data structures
SYNOPSIS use Data::Compare;
my $h1 = { 'foo' => [ 'bar', 'baz' ], 'FOO' => [ 'one', 'two' ] };
my $h2 = { 'foo' => [ 'bar', 'barf' ], 'FOO' => [ 'one', 'two' ] };
my @a1 = ('one', 'two');
my @a2 = ('bar', 'baz');
my %v = ( 'FOO', \@a1, 'foo', \@a2 );
# simple procedural interface
print 'structures of $h1 and \%v are ',
Compare($h1, \%v) ? "" : "not ", "identical.\n";
print 'structures of $h1 and $h2 are ',
Compare($h1, $h2, { ignore_hash_keys => [qw(foo)] }) ? '' : 'not ',
"close enough to identical.\n";
# OO usage
my $c = new Data::Compare($h1, \%v);
print 'structures of $h1 and \%v are ',
$c−>Cmp ? "" : "not ", "identical.\n";
# or
my $c = new Data::Compare;
print 'structures of $h and \%v are ',
$c−>Cmp($h1, \%v) ? "" : "not ", "identical.\n";
DESCRIPTIONCompare two perl data structures recursively. Returns 0 if the structures differ, else returns 1. A few data types are treated as special cases: Scalar::Properties objects This has been moved into a plugin, although functionality remains the same as with the previous version. Full documentation is in Data::Compare::Plugins::Scalar::Properties. Compiled regular expressions, eg qr/foo/ These are stringified before comparison, so the following will match: $r = qr/abc/i;
$s = qr/abc/i;
Compare($r, $s);
and the following won't, despite them matching *exactly* the same text: $r = qr/abc/i;
$s = qr/[aA][bB][cC]/;
Compare($r, $s);
Sorry, that's the best we can do. CODE and GLOB references These are assumed not to match unless the references are identical − ie, both are references to the same thing. You may also customise how we compare structures by supplying options in a hashref as a third parameter to the Compare() function. This is not yet available through the OO-ish interface. These options will be in force for the *whole* of your comparison, so will apply to structures that are lurking deep down in your data as well as at the top level, so beware! ignore_hash_keys an arrayref of strings. When comparing two hashes, any keys mentioned in this list will be ignored.
CIRCULAR STRUCTURESComparing a circular structure to itself returns true: $x = \$y;
$y = \$x;
Compare([$x, $y], [$x, $y]);
And on a sort-of-related note, if you try to compare insanely deeply nested structures, the module will spit a warning. For this to affect you, you need to go around a hundred levels deep though, and if you do that you have bigger problems which I can't help you with ;−)
PLUGINSThe module takes plug-ins so you can provide specialised routines for comparing your own objects and data-types. For details see Data::Compare::Plugins. Plugins are *not* available when running in ‟taint” mode. You may also make it not load plugins by providing an empty list as the argument to import() − ie, by doing this: use Data::Compare ();
A couple of functions are provided to examine what goodies have been made available through plugins: plugins Returns a structure (a hash ref) describing all the comparisons made available through plugins. This function is *not* exported, so should be called as Data::Compare::plugins(). It takes no parameters. plugins_printable Returns formatted text
EXPORTSFor historical reasons, the Compare() function is exported. If you don't want this, then pass an empty list to import() as explained under PLUGINS. If you want no export but do want plugins, then pass the empty list, and then call the register_plugins class method: use Data::Compare ();
Data::Compare−>register_plugins;
or you could call it as a function if that floats your boat.
SOURCE CODE REPOSITORY<git://github.com/DrHyde/perl−modules−Data−Compare.git>
BUGSPlugin support is not quite finished (see the the Github issue #5 <http://github.com/DrHyde/perl-modules-Data-Compare/issues/5> for details) but is usable. The missing bits are bells and whistles rather than core functionality. Plugins are unavailable if you can't change to the current directory. This might happen if you started your process as a priveleged user and then dropped priveleges. If this affects you, please supply a portable patch with tests. Bug reports should be made on Github or by email.
AUTHORFabien Tassin <fta@sofaraway.org> Portions by David Cantrell <david@cantrell.org.uk>
COPYRIGHT and LICENCECopyright (c) 1999−2001 Fabien Tassin. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Some parts copyright 2003 − 2014 David Cantrell. Seeing that Fabien seems to have disappeared, David Cantrell has become a co-maintainer so he can apply needed patches. The licence, of course, remains the same. As the ‟perl licence” is ‟Artistic or GPL, your choice”, you can find them as the files ARTISTIC.txt and GPL2.txt in the distribution.
SEE ALSOTest::Deep::NoTest perl (1), perlref (1) 0
Johanes Gumabo
Data Size : 16,708 byte
man-Data::Compare.3pmBuild : 2024-12-05, 20:55 :
Visitor Screen : x
Visitor Counter ( page / site ) : 5 / 169,124
Visitor ID : :
Visitor IP : 18.188.218.134 :
Visitor Provider : AMAZON-02 :
Provider Position ( lat x lon ) : 39.962500 x -83.006100 : x
Provider Accuracy Radius ( km ) : 1000 :
Provider City : Columbus :
Provider Province : Ohio , : ,
Provider Country : United States :
Provider Continent : North America :
Visitor Recorder : Version :
Visitor Recorder : Library :
Online Linux Manual Page : Version : Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page : Library : lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page : Library : lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base : Version : Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base : Library : lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36
Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.
ERROR : Need New Coding : (parse_manual_page_|249|Data::Compare.3pm|36/37|el══─{─══.|.el══─{─══. ds -- \|\(em\|
) (htmlprn|149|Data::Compare.3pm|36/37|.el══─{─══. ds -- — |.el══─{─══. ds -- \|\(em\|
) (parse_manual_page_|249|Data::Compare.3pm|43|br══─}─══|'br══─}─══
) (htmlprn|149|Data::Compare.3pm|43|'br══─}─══ |'br══─}─══
)