in reply to Shortening Execution Time

Assuming the fork doesn't fail, you do get transfers in parallel. However, both the parent and the child will print the content type and the Transfer Complete message.

You may want to exit() in the child, and wait() in the parent. And you may want to check whether the transfer actually succeeded, currently you print Transfer Complete, regardless whether it actually succeeded or not.

Replies are listed 'Best First'.
Re^2: Shortening Execution Time
by Perlbotics (Archbishop) on Aug 09, 2008 at 22:00 UTC
    Unix (flavours; don't know what Windows does): Additionally, you might want to catch or ignore the SIGCHLD-signal that the parent process receives when the child process dies. If there is only one child process, a $SIG{CHLD} = sub { wait(); }; as described in perlipc can be used as a starter. This should protect the parent process in case the child process dies while the parent process has not yet reached wait() (race situation).
    Update: Well, after some testing, this seems to be an issue with older versions of perl and OS. The default SIGCHLD-handler of Perl 5.8.8 (Linux) works fine. Anyway, the SIG-handler might be useful if you are interested in an asynchronous notification of a child's decease.