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