Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

deepequals

by Anonymous Monk
on Aug 28, 2002 at 00:24 UTC ( #193318=perlquestion: print w/replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Im trying to find a deepequals function/method, something like
$b = dclone($a);
if (deepequals($a,$b) {
   print " $a $b are equal, one is a clone of the other\n";
}
is there such a beast on CPAN that I missed ?

Replies are listed 'Best First'.
Re: deepequals
by merlyn (Sage) on Aug 28, 2002 at 00:31 UTC
Re: deepequals
by sauoq (Abbot) on Aug 28, 2002 at 00:44 UTC

    Storable provides that through the $Storable::cannonical variable. Quoting from the documentation:

    Normally, Storable stores elements of hashes in the order they are stored internally by Perl, i.e. pseudo-randomly. If you set $Storable::canonical to some TRUE value, Storable will store hashes with the elements sorted by their key. This allows you to compare data structures by comparing their frozen representations (or even the compressed frozen representations), which can be useful for creating lookup tables for complicated queries.
    -sauoq
    "My two cents aren't worth a dime.";
    
Re: deepequals
by rinceWind (Monsignor) on Aug 28, 2002 at 09:46 UTC
    I did ask something similar before in Need a test for deep equality. I know that storable and Data::Dumper have been revamped in the mean time, but please look at my conclusions in that thread.

    Super Search is your friend.

    --rW

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://193318]
Approved by myocom
help
Chatterbox?
[ambrus]: Today I accidentally cut my hand while carrying a computer. On the display part of the motherboard that sticks out at the back of the chasis and has ports, there's this thin metal sheet with holes cut for the ports, to guide plugs into the sockets.
[ambrus]: This sheet has sharp needle-like parts, 0.004 long and less than 0.001 wide, that can get bent to point outwards, and one of these cut into my palm when I lifted the box.
[ambrus]: So now when I choose what motherboard to buy for my new home computer, I have one more specific property to guide me. Useful, because there's so many different boards to choose from.
[Corion]: Well, no computer will start up without the blood sacrifice being made!

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (10)
As of 2017-01-16 19:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (151 votes). Check out past polls.