in reply to (my?) problem with re-blessed references(?)
The problem doesn't have anything to do with bless, but rather with the fact that you are storing your instance variables in the package scoped lexicals %phrase, %author, %approved and %date. This is equivalent to private static variables in C++/Java, and means that only one instance of each exists per package, all shared between instances of the class. Thus, the last created object overwrites those values. Variables declared using use vars or our are basically equivalent to public static in that you can refer to them from outside the package, i.e., %Quote::phrase, but are likewise shared among all instances.
If you want unique data per instance, you'll need to store that data inside the object itself, which in this case means using a hash or array, not a scalar, as the blessed reference.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: (my?) problem with re-blessed references(?)
by chromatic (Archbishop) on Dec 13, 2002 at 07:50 UTC | |
by jreades (Friar) on Dec 13, 2002 at 11:34 UTC | |
by djantzen (Priest) on Dec 13, 2002 at 11:42 UTC | |
by BrowserUk (Patriarch) on Dec 13, 2002 at 11:47 UTC |