Perl exec Function



Description

This function executes a system command (directly, not within a shell) and never returns to the calling script, except if the command specified does not exist and has been called directly, instead of indirectly through a shell. The operation works as follows −

If there is only one scalar argument that contains no shell metacharacters, then the argument is converted into a list and the command is executed directly, without a shell.

If there is only one scalar argument that contains shell metacharacters, then the argument is executed through the standard shell, usually /bin/sh on Unix.

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 −

exec EXPR LIST

exec LIST

Return Value

This function returns 0 only if the command specified cannot be executed.

perl_function_references.htm
Advertisements