Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Clawing my way out of operator overloading hell

by graff (Chancellor)
on Aug 01, 2003 at 04:15 UTC ( #279848=note: print w/replies, xml ) Need Help??

in reply to Clawing my way out of operator overloading hell

The first two replies above (Elian and sauoq) are fine for the situation where you may be handling multiple references to the same instance of an object. But there may also be the case where two independent data structures (two separate instances of the same type of object) are created and populated, and happen to end up containing identical data values. Just comparing the object handles won't detect this sort of identity.

I wonder whether Data::Dumper might provide a useful shortcut in this case (I haven't had occasion to use it myself yet) -- if nothing else, you may be able pass the Dumper's output for each object to Digest::MD5, and see whether the two objects have identical signatures.

update: Having just read the first paragraph of the OP more carefully, I realize that I missed the point and my remarks are not relevant (interesting, maybe, but not relevant). Elian and sauoq are right -- whoever wrote the original code was simply checking to see whether $obj1 and $obj2 were both references to the same instance of an object.

(one more update: since you're trying to scope out someone else's complicated, multi-file perl code, I could put in a plug for a tool I posted here to tabulate subroutines in multiple related perl files (calls and definitions). Hope it helps.

  • Comment on Re: Clawing my way out of operator overloading hell

Replies are listed 'Best First'.
Re: Re: Clawing my way out of operator overloading hell
by fergal (Chaplain) on Aug 01, 2003 at 16:21 UTC
    Further to your interesting but irrelevant remarks, if you want to compare 2 deep data structures, you can use Test::More's is_deeply() or Test::Deep's cmp_deeply(). is_deeply currently has a few bugs, it can't handle circular structures (fixes are in the pipeline). cmp_deeply has no bugs (cough!) and can do all sorts of weird and wonderful things (hence the need for a new module).

    Both of these modules will give you nice diagnostics about where the structures differ.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (9)
As of 2019-06-18 21:01 GMT
Find Nodes?
    Voting Booth?
    Is there a future for codeless software?

    Results (82 votes). Check out past polls.

    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!