in reply to Re^2: Problem with Inheriting a Super Class
in thread Problem with Inheriting a Super Class
With that in mind, could this be what is causing my problems?
I skimmed that part the first time, but you're right. It's definitely causing you problems. Here's a hint; this is a closure:
*$datum = sub { shift; # XXX: ignore calling class/object $self->{$datum} = shift if @_; return $self->{$datum}; };
In other words, every time you create a new object, you create a new closure bound to that new $self. Every time you call an accessor or mutator on an existing object, that accessor or mutator uses the values of the most recently created object.
The immediate fix is to look at the XXX comment and make that generated method not close over $self. A better fix overall is not to generate (and clobber previously generated!) accessor and mutator methods in your constructor.
Improve your skills with Modern Perl: the free book.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Problem with Inheriting a Super Class
by PyrexKidd (Monk) on Sep 20, 2011 at 00:00 UTC | |
by chromatic (Archbishop) on Sep 20, 2011 at 05:12 UTC | |
by PyrexKidd (Monk) on Sep 20, 2011 at 20:12 UTC | |
by chromatic (Archbishop) on Sep 20, 2011 at 21:43 UTC | |
by Anonymous Monk on Sep 20, 2011 at 00:21 UTC |