if(exists($foo{bar}) and exists($foo{bar}{baz})) { print "\$foo{bar}{baz} exists\n"; }