if ($rec{NOTE} && exists $rec{NOTE}{Nested}) {
More-DRY versions:
if( exists ${ $rec{NOTE} || {} }{Nested} ) { # or if( ( $rec{NOTE} || {} )->{Nested} ) { # or if( exist +( $rec{NOTE} || {} )->{Nested} ) {
Though, I find that I use those less often to avoid auto-viv and more often to prevent a potential fatal "Can't use undef as HASH ref" (something that I think should at least be turned into just a warning -- since sometimes it is fatal and sometimes it is a silent success, and I'm not even sure what distinguishes between those two behaviors).
- tye
In reply to Re^2: gotchas with hash element autovivification (dry)
by tye
in thread gotchas with hash element autovivification
by raybies
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |