in reply to Merging two pipes

Oh well, if we're all having a go...

You need to monitor some script, and at certain points start other scripts, and monitor those too?

open HANDLE, "some_script |"; push @INPUT, *HANDLE; while (<@INPUT>) { if ($some_condition) { open HANDLE, "some_other_script |"; push @INPUT, *HANDLE; } do_something_with_input(); }
Where <@INPUT> is pseudo-code for reading from one of the files in @INPUT, without blocking.

The perl cookbook suggests:

use IO::Select; $select = IO::Select->new(); # repeat next line for all filehandles to poll $select->add(*FILEHANDLE); if (@ready = $select->can_read(0)) { # input waiting on the filehandles in @ready }
to perform this check. Putting the two together is left as an excercise for the reader.