I can't post the real code because it's a small part of a huge script which requires productive database data.
Take an axe and freely hack away anything not related to the compare problem. ;-)
Try the following steps, in order:
- Add use Data::Dumper; to your script. Use the OOP variant to dump variable NAMES and values, as in print DEBUGLOG Data::Dumper->new([$foo,$bar],['foo','bar'])->Useqq(1)->Indent(1)->Dump();. Take a deep breath and look at what Data::Dumper reports. Are the values in the dump equal to the values that you expect? If not, why do your code and your expectations differ?
- Does your script (including all self-made modules) use strict, use warnings as it should? If not, add both. Any traces of no warnings, no strict, assignment to $^W in the code? If yes, remove them. Both will make perl complain loudly about some common problems. Fix those problems. no warnings, no strict and $^W should be rarely needed and be limited to very small blocks. $^W outside a block or without local is almost always an error. $^W should be replaced by no warnings qw( ... ), limiting what warnings are disabled. Run the script and look for compare errors. If they are gone, thank for strict and warnings.
- Create a new script containing only use strict; use warnings;. Use Data::Dumper to dump some relevant values from the original script. Try to limit the dump to a few cases, preferably a few that compare ok and a few that don't. If you have no better idea, dump only the first ten or so. Copy and paste the dump into the new script. (Remember that Data::Dumper produces executable perl code.) Copy and paste the compare part into the new script. Add minimal code to run over the hardcoded values from Data::Dumper and call the compare code. If that script still compares different things as equal, post the new script here as is.
Alexander
--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)