in reply to What habits do you have to avoid introducing bugs?

One thing to do is to make sure that you are using the functions correctly. fork returns undef on an error. When successful, to the parent process it returns a non-zero number (the pid of the child), and to the child it returns 0. At least that's the way it works under Unix-like versions of perl.