Newbee21369
Programmer
I was wanting to execute no more than 3 external scripts simultanously.. would it be best to use the fork or the system command?
Thanks!
Thanks!
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
use strict;
use warnings;
use Parallel::ForkManager;
my @sleepy_times=(3,5,2,8,1,6,4,7,9,10);
my $pm = new Parallel::ForkManager(10);
foreach my $sleepy_time (@sleepy_times) {
$pm->start and next; # do the fork
print "sleeping for $sleepy_time seconds\n";
sleep $sleepy_time;
print "done ($sleepy_time)\n";
$pm->finish; # do the exit in the child process
}
$pm->wait_all_children;