[Chapter 3] 3.2.34 exists
Author: Larry Wall, Tom Christiansen & Randal L. Schwartz
Date: 1999-07-02T01:49:16Z

#

| Chapter 3 Functions |

### 3.2.34 exists

    exists EXPR

This function returns true if the specified hash key exists in its hash, even if the corresponding value is undefined.

    print "Exists\n" if exists $hash{$key};
    print "Defined\n" if defined $hash{$key};
    print "True\n" if $hash{$key};

A hash element can only be true if it's defined, and can only be defined if it exists, but the reverse doesn't necessarily hold true in either case.

`EXPR` can be arbitrarily complicated as long as the final operation is a hash key lookup:

    if (exists $ref->[$x][$y]{$key}) { ... }

3.2.33 exec |  | 3.2.35 exit