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:

  1. 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?
  2. 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.
  3. 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". ;-)

In reply to Re^3: string compare matches incorrectly by afoken
in thread string compare matches incorrectly by Yaerox

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.