Jump to content

Perl Programming/Keywords/exec

From Wikibooks, open books for an open world
Previous: eval Keywords Next: exists

The exec keyword

[edit | edit source]

exec executes a system command and quits the Perl program. To return back, system should be used. The only way exec returns, if the command does not exist and it is executed directly instead of via your system's command shell. In this case, it fails and returns false.

Syntax

[edit | edit source]
  eval EXPRESSION
  eval PROGRAM LIST

Examples

[edit | edit source]
  exec ('foo') or print STDERR "couldn't exec foo: $!";

See also

[edit | edit source]
Previous: eval Keywords Next: exists