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 reply to Re^2: Data Object compares? by perl-diddler
in thread Data Object Verification Modules? by mwb613

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.