I've found:
The documentation for the exists operator no longer says that autovivification behaviour "may be fixed in a future release". We've determined that we're not going to change the default behaviour. perl #127712
perl #127712
I understand that there are only two options:
- NO autovivification. Then you can't do if (exists $h{a}{b}{c}{d}) { ... }, because you try to dereference non-existent $h{a}{b}, then you get error.
- Or default (*) behaviour, WITH autovivification, that is when you do if (exists $h{a}{b}{c}{d}) { ... }, then perl will gracefully create $h{a}, $h{a}{b}, $h{a}{b}{c} for you :) :)
(*) -- this is the default behaviour that creators of perl decided not to change
I hoped to find solution that doesn't autovifify when existence is checked, so I could just act like this if (exists $h{a}{b}{c}{d}) { ... } and not like this if (exists $h{a} && exists $h{a}{b} && exists $h{a}{b}{c} && exists $h{a}{b}{c}{d}) { ... }
My preferred default behaviour would be to return undef for $h{a}{b}{c}{d} and NOT create $h{a}, $h{a}{b}, $h{a}{b}{c}... This is not possible.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.