in reply to Comparing arrays
with the usual caveats... No nested structures, for example. If you're in that case, I too would try freezing the arrays, but with Storable, and compare the strings. (In case there could be hashes in there, check out the section entitled "canonical representation" in the docs.) Oops, no special modules, you said?...sub array_eq { my($ar1, $ar2) = @_; @$ar1 == @$ar2 or return 0; return !grep { $ar1->[$_] ne $ar2->[$_] } 0 .. $#$ar1; } print array_eq (['one', 'two', 'three'], ['three', 'one', 'two']) ? + 'the same' : 'different';
|
---|