Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: string compare matches incorrectly

by afoken (Chancellor)
on May 22, 2015 at 11:01 UTC ( [id://1127461]=note: print w/replies, xml ) Need Help??


in reply to Re^2: string compare matches incorrectly
in thread string compare matches incorrectly

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". ;-)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-03-29 06:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found