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