Yes, I fully agree with you, and it is a pretty clever way ++. I probably would not have thought about simply silencing out undef warnings and still get a rather consistent output, but would have probably gone through a more complicated conditional expression to check for "definedness" (if that word exists) of both variables before comparing them and return the right positive, negative or null value depending on the case..
But, in the case in point, I just wanted to give a different example showing how to do the task in broad terms, and let the OP give more precise specifications on the edge cases (especially given that there are other edge cases, such as empty strings, etc.). I am working almost daily with incomplete specifications, and can usually work my way around that because I have also a good functional knowledge on most of the applications on which I am working, but that is also getting sometimes on my nerves, because there are cases where I just do not know well enough the functional context. So, when I don't know the context well enough, as in the case we are talking about in this thread, I am often preferring to just play it a bit stupid and say: "Tell me exactly what you want it to do, and I'll try to do it for you. But don't expect me to take the decisions for you just because you are unsure of what they should be, because I don't want you to then reject these decisions and tell me it is a development bug when you figure out later that you really needed something else than what you specified. Take your responsibilities, and I'll take mines." Not that I have any hostility against people making the specifications, I have also been doing that job for years, I know it is not always easy. And, often enough, a phone call or a mail exchange can clarify the issue.
Well, I am getting somewhat off-topic here, sorry about that. To summarize, I'll be happy to provide another version of my proposed solution if the OP gives precise information on how this should work for edge cases. If not, then, at least, I think you and I have provided good examples on how to do it, they can be adapted to real needs.