needperlhelp has asked for the wisdom of the Perl Monks concerning the following question:

Hello, is there a way to start a program from perl but don't wait for it to complete.

`program`;
system("program");
exec("program");

All these wait for the "Program" called to complete,
untill such time the perl script blocks, I dont want this to happen,
i only want to start the program, even if it fails it is not a problem.

Thanks

Replies are listed 'Best First'.
Re: Spawn a New Process and detach
by tirwhan (Abbot) on Dec 16, 2005 at 09:31 UTC
Re: Spawn a New Process and detach
by salva (Canon) on Dec 16, 2005 at 09:34 UTC
    On linux/unix systems you can use:
    fork or exec("program", @args);
    On windows (and unix also) you can use Proc::Background
Re: Spawn a New Process and detach
by Mandrake (Chaplain) on Dec 16, 2005 at 10:40 UTC
    I think
    system("program &") ;
    should work. Running the program in background allows your script to continue with rest of the code.
    Am I missing anything?

    Thanks..
Re: Spawn a New Process and detach
by spurperl (Priest) on Dec 16, 2005 at 09:30 UTC
    If you are on Unix, use "fork".

    On Windows, I found Win32::Process quite useful