Sewi has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks,
I need to track changes deep into a hash (or array) reference.
sub foo { my $self = shift; $self->{changed}->{foo} = shift if $#_ > -1; return $self->{changed}->{foo} || $self->{data}->{foo}; } $x->foo('bar'); # This is recognized push @{ $x->foo->{bar}->{itemlist} },1; # This isn't
(I shortened the return part of foo, the original one is also dealing with undef values correctly.)
If foo holds a hash ref, the structure below this is completely unpredictable. Converting everything into a deep object structure (= $x->foo->bar->itemlist) would take a lot of time.
(How) could the "parent" package $x get some kind of notification if any deep value is changed?
I'd like to avoid a deep comparison between $self->{data} and $self->{changed}
Thank you all
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Deep-bless a HASH
by kennethk (Abbot) on May 31, 2011 at 14:29 UTC | |
|
Re: Deep-bless a HASH
by Sewi (Friar) on May 31, 2011 at 14:17 UTC | |
|
Re: Deep-bless a HASH
by GrandFather (Saint) on May 31, 2011 at 21:43 UTC | |
|
Re: Deep-bless a HASH
by bluescreen (Friar) on May 31, 2011 at 23:28 UTC |