Let me see ... how many times have I spent time hunting a bug caused by autovivification during my ten years with Perl ... zero. How many times did it save me from code like if($data and $data->{foo} and $data->{foo}{bar} and $data->{foo}{bar}{baz} and $data->{foo}{bar}{baz}{bat}) or
? Countless.if (!exists($data->{$key}) { $data->{$key} = []; } push @{$data->{$key}}, $new_value;
If you hear about autovivification for the first time it may sound scary, but you do get used to it. And the problems caused by autovivification are few and far apart.
In reply to Re^2: Why does exists cause autovivication?
by Jenda
in thread Why does exists cause autovivication?
by Argel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |