use strict; use warnings; #1176332 my $cmd_1 = "perl 1176332p2.pl"; # (renamed from OP's hello.pl) open (CMD, "$cmd_1 2>&1|") or warn ("!!! Can't run program: $!\n"); my $start = time(); printf "Started at %s\n",$start; while (my $line = ) { print "->" . $line; if (time() > $start + 2) { printf "Stopping at %d!\n",time(); last; } if ($line =~ m/^xyz/) { print "\n Pretending to do some string manipulation\n"; } else { print "(from $0): Nothing yet | "; } } close CMD; printf "Actually stopped at %d\n", time();