if(exists $foo{'bar'} and exists $foo{'bar'}{'baz'} and exists $foo{'bar'}{'baz'}{'qux'}) { ... }