Just another Perl shrine | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Yes, this is simple for the experienced programmer who is comfortable with the whole notion of references, but not so simple for the programmer who is just beginning to work with them. I know from helping newbies at work that references don't come easy to many people for some reason. And even in the best of cases, one first has to become sensitized to the possibility of autovivification-mediated trouble before one develops an eye for unintended autovivification. This is true for just about any class of bugs. (perlreftut, perlref, and perltrap need to do more towards alerting programmers to autovivification bugs.) And even with a bit of experience, something like this: can silently trip you. Or, while it's clear that is dereferencing, and hence autovivifying, $h{ wild_guess }, it is less clear (or at least it was so to me) that is also autovivifying $h{ wild_guess } Update: What am I saying?! Of course there is dereferencing in %{ $h{ wild_guess } }. So "asked to interpret an undef as if it were..." is just a wordier way to say "dereference". I confess that I find it more intuitive somehow, but I'd still say that your Simple is much simpler than mine. Update: Added perltrap to the docs list above. the lowliest monk In reply to Re^2: The Bad, the Ugly, and the Good of autovivification
by tlm
|
|