That Q&A reference explains to the original poster how to see if a particular value is in a hash, or if a particular hash key contains a specific value.
The OP's question was, what is the proper way to check for the existance of a particular hash key, which is quite different from the answer implied in your response.
If his objective is to verify that $hash{key} has been created (and thus exists), he should use the construct that Liz provided: if (exists $hash{key} ) { ....do your stuff.... }. Again, exists will tell you if a hash key has been brought into existance, which seems to be the answer the OP was asking for.
On the other hand, if someone is interested in whether a particular key's value has been defined, one would use the defined function as in, if (defined $hash{key} ) { ....do your stuff....}
Defined differs from exists in that defined returns true if the hash's key's value has been defined, and false if the hash's key's value is undef. But it doesn't care whether or not the hash's key has been created or not. In other words, using defined, you don't know if it is returning false because the key is nonexistant, or because the value referred to by the key is undef. It makes no distinction. Defined is also applicable to other forms of scalars and function returns even.
Hope this helps.
Dave
"If I had my life to do over again, I'd be a plumber." -- Albert Einstein |