in reply to how can we tell when a background process is finished?

You may use the trick running

my $pid = (`program &;echo $!`)[0];

which gives you the id of background process. Then you may wait for this process to end.

Not a very clever solution but you may have a try.

[approx. syntax, please check...]

--
HTH, Dominique
If the only tool you have is a hammer, you will see every problem as a nail.
-- Abraham Maslow