gryng has asked for the wisdom of the Perl Monks concerning the following question:
I have a much larger program that this goes with, but even the smaller example does not seem to work. I tried initially to use the pipe command, and then switched to open(READ, "-|") command -- but both exhibit the same behavior: I do not get any data from the child until the child closes his end. Here is my example code:
I receive this as output:#!/usr/bin/perl -w use strict; if (my $pid = open(READ, "-|")) { print "child said: '", <READ>, "'; ",time,"\n"; print "child said: '", <READ>, "'; ",time,"\n"; } else { print "hello; ",time,"\n"; sleep 2; print "how are you; ",time,"\n"; }
gryn@echor:~$ ./testcase.pl child said: 'hello; 1005587480 how are you; 1005587482 '; 1005587482 child said: ''; 1005587482
I'm quite perplexed, and I've read over and over the various examples in the documentations (such as perlipc's numerous ones). I just can figure it out.
I am running with perl 5.6, on a intel debian unstable box; in case that matters.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Open, ye! And read from your child!
by runrig (Abbot) on Nov 12, 2001 at 23:08 UTC | |
by gryng (Hermit) on Nov 13, 2001 at 01:42 UTC | |
|
Re: Open, ye! And read from your child!
by belg4mit (Prior) on Nov 12, 2001 at 23:01 UTC | |
|
Re: Open, ye! And read from your child!
by Zaxo (Archbishop) on Nov 12, 2001 at 23:17 UTC |