Perl exists Function

Advertisements


Description

This function 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.

If LIST is more than one argument, or an array with more than one value, then the command is executed directly without the use of a shell.

Syntax

Following is the simple syntax for this function:

exists EXPR

Return Value

This function returns 0 if hash element or array index does not exist, or if the subroutine has not been declared and 1 if hash element or array index does exist, or if the subroutine has not been declared.

Example

Following is the example code showing its basic usage:


When above code is executed, it produced following result:




Advertisements
Advertisements