wrote:
> Hi folks,
>
> it's probably a simple question...
>
> I want to start several processes with perl whose names are stored in
> an array. Before calling/executing the next file I want to wait a
> certain time.
>
> How do I have to modify the example below?
>
> # Run multiple background processes.
> my @processes = ("process01.exe 1",
> "process02.exe 2",
> "process03.exe 3");
>
> unless (fork)
> {
> # running as child process
> exec $_ or die "Exec of $_ failed!"; # shouldn't happen
> } # only parent runs here
> }
>
> Has anyone a suitable solution? That'd be kind?
you can use Proc::Queue for that:
use Proc::Queue qw(system_back);
Proc::Queue::delay(10); # sets min delay between fork calls
Proc::Queue::size(5); # sets max number of children
system_back $_ for @processes;
Cheers,
- Salvador