when you call the fork function ("if(fork())" does this)
the current process get duplicated and the 2 processes keep running from the point
where you called fork.
now the only way you have to know if you are the parent or the child process is to test
the exit status of fork() (here cames if(fork()) )
fork return 0 to the child and the pid of the child to the parent (!=0 then true)
so you put the code for the parent in the if block and the code for the child in the else block...
please look at "perldoc -f fork" for more info.