Beefy Boxes and Bandwidth Generously Provided by pair Networks
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??


in reply to Re: Data Object compares?
in thread Data Object Verification Modules?

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1216067]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2024-03-28 17:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found