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.
In reply to Open, ye! And read from your child! by gryng
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |