if ($foo and $foo->{bar}->{baz}) {...}