in reply to Are defined or // garantee not to autovivify?
Hello NisSam, and welcome to the Monastery!
Further to hippo’s answer, I just want to point out that even using exists doesn’t ensure that autovivification won’t occur:
0:33 >perl -Mstrict -MData::Dump -wE "my %h = (A => 'a'); if (exists +$h{B}{C}) { say 'yes'; }; dd %h;" ("B", {}, "A", "a") 0:33 >perl -Mstrict -MData::Dump -wE "no autovivification; my %h = (A + => 'a'); if (exists $h{B}{C}) { say 'yes'; }; dd %h;" ("A", "a") 0:33 >
— as explained in the documentation for the exists function. So, as hippo says, using no autovivification; is the safest option.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|