Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: recursively comparing heterogenous data structures

by bikeNomad (Priest)
on Jul 07, 2001 at 22:01 UTC ( [id://94749]=note: print w/replies, xml ) Need Help??


in reply to recursively comparing heterogenous data structures

Another way to compare arbitrary data structures (if you just need to see if they're different, and don't care about CODE or GLOB reference differences internally):

use Storable; $Storable::canonical = 1; my compare { Storable::freeze($_[0]) eq Storable::freeze($_[1]) }

update:The above gets hashes right (by sorting their keys); however, it doesn't allow ignoring ordering of lists as the original code does.

Replies are listed 'Best First'.
Re: Re: recursively comparing heterogenous data structures
by thraxil (Prior) on Jul 08, 2001 at 01:31 UTC

    that's pretty useful. unfortunately, it is order dependent. i wrote the code above because i had data structures to compare and i didn't care about the order of any lists within; just whether or not they had the same elements.

    anders pearson

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://94749]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-25 08:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found