in reply to Waiting for an external process to end?

1) close() won't return until the process has finished. From "perldoc -f close":

Closes the file or pipe associated with the file handle, returning true only if stdio successfully flushes buffers and closes the system file descriptor.

Closing a pipe also waits for the process executing on the pipe to complete, in case you want to look at the output of the pipe afterwards, and implicitly puts the exit status value of that command into "$?".

2) try waitpid $pid

(Update: add perldoc snippet to 1)