i just realized upon reviewing your description that you want to run a round of burns, then reload all drives at the same time, then do another round, etc. to achieve this, replace the main loop with this:
my $chld;
while (@data) {
while (@resource) {
last unless @data;
my $resource = shift @resource;
my $data = shift @data;
if (($chld = fork()) > 0) {
# parent code
$jobs{$chld} = $resource;
} else {
# child code
runcmd($resource, $data);
exit; # end chld, trigger $SIG{CHLD}
}
}
sleep until @resource == $num_resources;
print "ONE ROUND DONE";
last unless @data;
print "RELOAD THEN PRESS ENTER: ";
<>;
}
perl -e'$_="nwdd\x7F^n\x7Flm{{llql0}qs\x14";s/./chr(ord$&^30)/ge;print'