I don't like your ref-based test (it will give both false positives and false negatives). I'd just be sure to 'use strict' and do 'if $hash && $hash->{1}' instead. Perhaps 'if ref($hash) && $hash->{1}' would also be okay.
Note that you can also use Data::Diver to avoid autovivification.
I'd still really like to have a 'no autovivify' pragma... (:
- tye
In reply to Re^2: Testing a key creates a hash (ref--)
by tye
in thread Why does testing a key create a hash?
by johnnywang
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |