4 ms·
FWIW, you can 'lock down' a hash so that reads or writes of non-existing keys will cause a fatal error. Not only does this stop autovivification on 'writes' to
by joosters 7y ago
FWIW, you can 'lock down' a hash so that reads or writes of non-existing keys will cause a fatal error. Not only does this stop autovivification on 'writes' to a hash, but it will also help catch typos in your code just reading from the hash: e.g. if you accidentally wrote
$foo = $bar{Autovivication}
instead of
$foo = $bar{Autovivification}
in your program, it will abort instead of returning an undefined value :)
See Hash::Util for details.