Would this approach be a helpful alternative? (I ask because I'm not sure I entirely understand your real problem space.)

use strict; use warnings; #1176332 my $cmd_1 = "perl D:/_scratch/1176332p2.pl"; # (renamed from OP's hel +lo.pl) open (CMD, "$cmd_1 2>&1|") or warn ("!!! Can't run program: $!\n"); while (my $line = <CMD>) { print $line; if ($line =~ m/^xyz/) { print "\n Pretending to do some string manipulation\n"; } else { print "(from $0): Nothing yet | "; } } close CMD;
use strict; use warnings; # D:/_scratch/1176332p2.pl $| = 1; print "Hello World from 1176332 PART 2\n"; print "Sleeping 10 seconds \n"; for (1 .. 10) { sleep 1; print ". \n"; } print "xyz \n";

Execution:

D:\_scratch>D:\_scratch\1176332.pl Hello World from 1176332 PART 2 (from D:\_scratch\1176332.pl): Nothing yet | Sleeping 10 seconds (from D:\_scratch\1176332.pl): Nothing yet | . (from D:\_scratch\1176332.pl): Nothing yet | . (from D:\_scratch\1176332.pl): Nothing yet | . (from D:\_scratch\1176332.pl): Nothing yet | . (from D:\_scratch\1176332.pl): Nothing yet | . (from D:\_scratch\1176332.pl): Nothing yet | . (from D:\_scratch\1176332.pl): Nothing yet | . (from D:\_scratch\1176332.pl): Nothing yet | . (from D:\_scratch\1176332.pl): Nothing yet | . (from D:\_scratch\1176332.pl): Nothing yet | . (from D:\_scratch\1176332.pl): Nothing yet | xyz Pretending to do some string manipulation D:\_scratch>

If I've misconstrued your question or the logic needed to answer it, I offer my apologies to all those electrons which were inconvenienced by the creation of this post.

check Ln42!


In reply to Re: Run and kill external programm after x seconds by ww
in thread Run and kill external programm after x seconds by demichi

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.