in reply to Comparing unordered hierarchical arrays

After much testing, I was unsuccessful, but you might want to check out Test::Deep as a framework for your comparison, with repeated commands to bag() in some hierarchical manner. The fact that it already includes tools for doing deep array comparisons could make it a strong tool in your favor.

Update: Clarified last line.



Code is (almost) always untested.
http://www.justicepoetic.net/
  • Comment on Re: Comparing unordered hierarchical arrays

Replies are listed 'Best First'.
Re^2: Comparing unordered hierarchical arrays
by fergal (Chaplain) on Jul 11, 2004 at 18:26 UTC
    Better late than never! Test::Deep might be somewhat overkill but it certainly does the job
    use Test::Deep; my $ha = bag( bag(1,2), bag(5,5,5), bag(1,2), bag(3,4) ); my $hb = [ [4,3], [1,2], [2,1], [5,5,5] ]; print eq_deeply($hb, $ha) ? "same\n" : "different\n";