good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re^2: Data Object compares?by perl-diddler (Chaplain) |
on Jun 06, 2018 at 21:54 UTC ( [id://1216067]=note: print w/replies, xml ) | Need Help?? |
A few more things forgot to mention, about the return values: normally, if the structures are able to be compared, it will return -1, 0 or +1 meaning struct on left compared 'less', or equal or struct on rt.
The ordering of structures is definitely *arbitrary* or *subjective* -- I compare keys of hashes, for example, but whether or not that ordering is relevant or pertinent is entirely arbitrary -- as mentioned before, I really wanted to know if the structures were equal or not, but I figured, I might as well try *some* ordering and get some side benefit of possibly being able to sort data-structs into some order. For hashes, I then pull up the values for the keys and sort those and compare those. If you get back an 'undef', it means it couldn't compare it -- not that they were unequal(or equal). Even if the underlying data structures are the same -- if they are blessed data structs in different classes, they return undef. On return values, I use a 2 element array with the 2nd element being a number pointing at the test in the Cmp that failed. That helped me narrow down problems and such. They may or may not be useful.
In Section
Seekers of Perl Wisdom
|
|