It’s not the point of this distribution list to discuss Perl, but fork will return the process id for both processes. A simple pattern for the source code looks like:
pid = fork(); if (pid==0){print "do the child things";} else {print "do parent things"} You want to aim your script semantics according to the pid. This is because the source code is executed by both processes.