in reply to Fork horror

you seem to have the bit:
if(!defined($child = fork())) { die "Cannot fork: $!";
twice in a row, although that may have been an error in transcription. i would think it wouldn't run at all otherwise.