Here hash2 attribute is dependent on hash1. infact, hash2 is driven by hash1. for example,
hash1 -> key1 => value1, key2 => value2 etc..
hash2 -> key1 => 6, key2 => 6 etc. it is length(value from hash1, going to hash2)
Tried something like below, but not helpful.
has 'hash1' => (
is => 'rw',
isa => 'HashRef[Str]',
default => sub { {} },
handles => {
map { $_ . '_hash1' => $_ } @hash_delegations
},
);
has 'hash2' => (
is => 'rw',
isa => 'HashRef',
builder => '_filter_hash1',
handles => {
map { $_ . 'hash2' => $_ } @hash_delegations
},
);
sub _filter_hash1 {
my $self = shift;
for my $alias ($self->keys_hash1()) {
return {$alias, length($alias)};
}
}
Hash1 is going to set over time, not sure how to make sure that how should I capture the event on hash1 to update the entry in the hash2. Any idea how can I achieve this ?