in reply to Re: Mar
in thread re-using a hash reference (was: Mar)
When doing something equivalent to deep sea diving in your nested hashes, it is often easy to keep a pointer to a value or a point in the hash. For example, if you wanted the value of either 'c' or 'd' of the 'b' branch:if (my $value = $hash1->{a}->{b}->{c}) { $hash2->{bob} = $value; }
You would certainly want to make note of jeffa's remark about autovivification, though. If this structure were persistent, and large, then you would want to carefully test each branch before diving in.if (my $ref = $hash1->{a}->{b}) { $hash2->{bob} = $ref->{c} || $ref->{d}; }
|
|---|