That's the same thing as
if (defined($a->{b}))
Regarding the reply in the comments, defined
does not instantiate the keys.
>perl -E"if (exists($a->{b}) and defined($a->{b})) { } say 0+keys(%$a);"
0
>perl -E"if (defined($a->{b})) { } say 0+keys(%$a);"
0
->
, on the other hand, autovivifies as normal.
>perl -E"if (defined($a->{b})) { } say $a || 0;"
HASH(0x3fbd8c)
But that's the case for exists
too.
>perl -E"if (exists($a->{b}) and defined($a->{b})) { } say $a || 0;"
HASH(0x81bd7c)
If you're trying to avoid autovivification, you'd use
>perl -E"if ($a && defined($a->{b})) { } say $a || 0;"
0
or
>perl -E"no autovivification; if (defined($a->{b})) { } say $a || 0;"
0