open INPUT, "some_script |"; while () { if ($some_condition) { open ">&INPUT", "some_other_script |"; } do_something_with_input(); }