in reply to Re: batch processing via single open
in thread batch processing via single open

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?

Replies are listed 'Best First'.
Re^3: batch processing via single open
by daxim (Curate) on Jul 16, 2007 at 00:11 UTC
    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. }; };