Try opening pipes from both scripts at the start of your program, then make INPUT a duplicate of these filehandles, e.g.
open SCRIPT, "some_script |"; open OTHERSCRIPT, "some_other_script |"; open INPUT, ">&SCRIPT"; while (<INPUT>) { if ($some_condition) { close (INPUT); open INPUT,">&OTHERSCRIPT"; } do_something_with_input(); if ($some_other_condition) { close (INPUT); open INPUT,">&SCRIPT"; } }
Again the die statements have been left out - I'm sure you will want to put them in for production code.

I've not tested the above code, but looking at the open documentation this should be what you need.

Cheers,

JJ

Update: I've just read jeroenes reply, and I think that I may have misunderstood your question. Do you need both your inputs on the same filehandle?


In reply to Re: Merging two pipes by jj808
in thread Merging two pipes by cmburns

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.