in reply to efficient function

exec() executes an external program and never returns!

system() executes an external program and returns its exit status

They do different things!! They are both "inefficient" as they both involve starting another process.

Replies are listed 'Best First'.
Re^2: efficient function
by ikegami (Patriarch) on Aug 24, 2009 at 06:00 UTC

    Just wanted to add that system is basically fork + exec (in child) + waitpid (in parent) in unix systems.

    In Windows, system corresponds to CreateProcess + a wait function (such as WaitForSingleObject), while exec and fork are emulated by Perl since they're not supported by the OS.

    Update: Fixed error in Windows side.

      Ikegami, a most excellent post!

      However, I suspect that OP doesn't need either exec() or fork(), but of course we can't know that without further clarification.

      For the OP, there is no need for these in a normal single Perl program as there are modules and functions that can usually do what you need, and much more efficiently.