in reply to Fork and wait question

I'd like to second the recommendation to use Parallel::ForkManager. Friends don't let friends write their own fork() management code.

But I'd also like to draw your attention to something not yet pointed out - you seem to believe that you can run code after calling exec(). That's incorrect - exec() replaces the process with a new one and never returns. Sometimes you'll see:

   exec(...) or die(...);

But that's just there to handle the possiblity that exec() might fail. If exec() succeeds then that process won't be running your code anymore.

-sam