$ perl -wE' my %hash = ( a => 1 ); my $foo = $hash{foo}; if(defined $foo) { 1 } say keys %hash;' a