in reply to problem with forking

Perl forking 101:

#!/usr/bin/perl -w use strict; my $pid=fork(); # there's a fork in the road... if ($pid){ wait(); # Parents are always waiting around for children } else { # This is the child process... # hand waving... do stuff here... exit(0); } # and on our merry way we go.

There is a very simplified view of how forking works. The data space up until the time of the fork gets inherited by the child. In the child instance, $pid is going to be zero and in the parent process $pid will have the pid of the child process that is running. In the example I give above your parent process will wait until the child process exits (note the very implicit exit call, this prevents nasty things from happening if we fall through the if statement) before continuing execution.

another mouse trap!

There are ways of making your life easier when it comes to forking. Check out Proc::Fork and Schedule::Parallel::Fork just to name two.