sub getProc { #do some stuff } sub getInput { while() { # do some stuff up here... $childPid = fork(); #fork a process if($childPid == 0) { #okay, in the child #call getProc getProc(); } else { # okay, we are in the parent, # so, let's continuing doing what we do } } }