Syntax
Definition and Usage
Returns true if the specified hash or array key exists, regardless of the corresponding value, even if it.s undef. If EXPR is a subroutine, then exists will return 1 if the subroutine has been declared (but not necessarily defined), 0 if not.
Return Value
0 if hash element or array index does not exist, or if the subroutine has not been declared
1 if hash element or array index does exist, or if the subroutine has not been declared
Example
Following are the usage...
print "Exists\n" if exists $hash{$key};
print "Defined\n" if defined $hash{$key};
print "True\n" if $hash{$key};
print "Exists\n" if exists $array[$index];
print "Defined\n" if defined $array[$index];
print "True\n" if $array[$index];
print "Exists\n" if exists &subroutine_name;
print "Defined\n" if defined &subroutine_name;
|
|