# A.pl unless(fork) { sleep 1 until getppid == 1; for (1..10) { @argsfoo = ("$cd $TSTDIR; B.pl"); if (system(@argsfoo) != 0) { ... } else { ... } } exit 0; } wait;