![]() |
|
Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re^2: Preventing autovivificationby EvanCarroll (Chaplain) |
on Feb 16, 2010 at 04:43 UTC ( #823400=note: print w/replies, xml ) | Need Help?? |
In addition to this, you need to isolate the object (inside out) from the implementation (hash). In short, there is no way to stop an attribute from being added to a hash data structure. Auto-vivification is just part of the behavior of hashes.
You can achieve like-hashes that don't auto-vivify like this with Variable::Magic or Tie::HashRef, but I believe this to be outside the scope of the question.
With an inside hash, you would typically control autovivification with the set method.
In Section
Seekers of Perl Wisdom
|
|