in reply to Re: Seeking advice for OO-related strategy
in thread Seeking advice for OO-related strategy

It's usually cleaner to demote the object's data to a separate class owned by the parent object, or even just to a single data structure owned by the parent object:
Thank you for being so kind and take the time to answer my question. I'll take your advice into account, but still I fail to see how it can be related, if not marginally, to what I was asking...
Instead of this:
<SNIP>
do this:
package Parent_object; sub new { my $O = bless {}, shift; $O->{'data'} = _fill_attributes (@_); return ($O); } sub _fill_attributes { my $result = {}; $result->{'attribute-1'} = $_[0]; $result->{'attribute-2'} = $_[1]; $result->{'attribute-3'} = $_[2]; [....] return ($result); }
I see what you mean, but...
By demoting the data, you get rid of the circular dependency between the parent object and the user-supplied child function. The child function doesn't need to know anything at all about the parent object, it only needs to know the data object, or hash, or whatever.
OTOH Tanktalus' solution with a closure is just as fine in avoiding that kind of "circular dependency" and is more close to "the way I want to do it". And it can still apply to the code you supplied, since it has to do with the subs that get passed in, not to what's in the objects that will use them. So the two issues are mostly orthogonal, IMHO...