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?
Where <@INPUT> is pseudo-code for reading from one of the files in @INPUT, without blocking.open HANDLE, "some_script |"; push @INPUT, *HANDLE; while (<@INPUT>) { if ($some_condition) { open HANDLE, "some_other_script |"; push @INPUT, *HANDLE; } do_something_with_input(); }
The perl cookbook suggests:
to perform this check. Putting the two together is left as an excercise for the reader.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 }
|
|---|