Hello I have a script that, much like the Little Old Lady who lived in a shoe, has so many children it's not sure what to do.
Basically, the script does some stuff, then kicks off multiple copies of an external process that all run in parallel. It then has to wait until all of them have completed (successfully) then carry on with the next bit. What I've cobbled together so far (i.e. swiped of the web then modified...) use strict; use warnings; # Do some stuff here for (my $i=1; $i <=$num_processes; $i++) { defined(my $pid = fork) or die( "Cannot fork : $!\n"); # Put all the pids into an aray if ($pid) { push @pids, $pid; } else { exec "external giggery pokery" } } foreach my $child_pid (@pids) { waitpid($child_pid, 0); unless( 0==$? ) { die ("Oh No! An external process has failed!!\n"); } } # Do the next bit here It seems to work with a simplified test script, but I', worried I've done something stupid in there and the whole thing will explode when exposed to the live environment. Does this look sensible and/or is there a better way of doing this? And help/suggestions/criticisms gratefully received. Cheers Andy Capgemini is a trading name used by the Capgemini Group of companies which includes Capgemini UK plc, a company registered in England and Wales (number 943935) whose registered office is at No. 1 Forge End, Woking, Surrey, GU21 6DB. This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/