You're talking quite in the abstract here. What prevents you to implement exactly what you've said in the second paragraph? Do you know about subroutines? There's hardly a reason to have a perl file (program) call another one in a new process.
Because I don't know how to do it. How can a piece of code understand if there already exists a connection to an external program so that it can re-use it without opening a new one thus saving time?
our $ALREADY_CONNECTED = 0; # this var's purpose is called a semaphore
DOCUMENT:
for my $document (@collection) {
if (!$ALREADY_CONNECTED) {
open2(...); # and save the handles for later usage
$ALREADY_CONNECTED = 1; # whoa! magic!
redo DOCUMENT;
} else {
# blah blah process $document here,
# the in/out handles exist.
};
};