in reply to Re: subroutines which forks?
in thread subroutines which forks?

Except that does almost the exact equivalent of the OPs code! (Did you bother to look?)