open INPUT, "some_script |"; open OUTPUT, "| some_other_other_script "; while (){ if ($some_condition){ open INPUT2, "some_other_script |"; print OUTPUT $_ while ; } print OUTPUT $_; }