in reply to Re: Class::Std problem
in thread Class::Std problem

Howdy!

I take the question to be "how do I fix my 'new' so the code snipped works right?" If new({ id => 1 }) returns the same thing each time, the comparison should work fine. The trick is to get 'new' to not only construct one object for each distinct value of id that it sees.

yours,
Michael

Replies are listed 'Best First'.
Re^3: Class::Std problem
by Herkum (Parson) on Dec 21, 2006 at 13:20 UTC

    This was more along the lines of what I was looking for. I must have not made the problem clear enough because most of the posts focus upon the comparison aspect rather than the object generation.

    I use Class::Std to generate new objects. However, if I am getting an object that already exists, I wanted to return the existing object, not generate a new one for comparison. So in my example, if $manager1 was this 'Manager=SCALAR(0x83ef950)' then $manager2 would return the reference.

    After sleeping on it, I think that I just have to sub-class Class::Std that keeps track of all the existing objects and returns that object if it already exists.