in reply to Re: Share data bless hash of parent package with childs packages
in thread Share data bless hash of parent package with childs packages
Maybe the OP doesn't want to really share data, but wants the Parent class to provide fallback data. But maybe that shouldn't be per-class but more per-instance. Anyway, I would also recommend the OP use a getter/setter approach instead of reaching into the objects:
sub get( $self, $item ) { if( exists $self->{data}->{ $item }) { return $self->{data}->{ $item } } elsif( $self->{parent_data}->{ $item }) { return $self->{parent_data}->{ $item } } } sub set( $self, $item, $value ) { return $self->{data}->{ $item } = $value; }
|
|---|