Magius_AR has asked for the wisdom of the Perl Monks concerning the following question:
Here is the code I have so far that doesnt work:
# command < infile open (IN,"$infile"); @data = <IN>; close(IN); $pid = open(READ_FROM_CHILD,"-|"); unless (defined $pid) { die "cannot fork: $!"; } if ($pid) { @result = <READ_FROM_CHILD>; close(READ_FROM_CHILD); } else { $pid = open(WRITE_TO_CHILD, "|-"); unless (defined $pid) { die "cannot fork: $!"; } if ($pid) { print WRITE_TO_CHILD @data; close(WRITE_TO_CHILD); } else { exec "$path/$command"; } }
This doesn't work...@result is always empty. Also, the "print WRITE_TO_CHILD @data" line returns output to the screen when it should not be doing that (is STDOUT not getting redirected as it should?)
This problem has been plaguing me for days now...any help would be much appreciated.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Followup to redirecting filehandles
by ChOas (Curate) on Oct 23, 2000 at 13:07 UTC | |
|
Re: Followup to redirecting filehandles
by Magius_AR (Sexton) on Oct 23, 2000 at 13:12 UTC | |
|
Re: Followup to redirecting filehandles
by Magius_AR (Sexton) on Oct 23, 2000 at 13:15 UTC |