cmcmillo has asked for the wisdom of the Perl Monks concerning the following question:

Having a hard time writing to a process that I've written. I am unable to write to the opened process (thread_pool.test); Can anybody help?
writer:
file name: system_test.pl
open(TPOOL, "|thread_pool.test) || print "error: $!" && exit(1)); while(1) { sleep 10; print TPOOL "This is just a test\n"; } Reader: file name: thread_pool.test while(1) { my $input = <STDIN>; log("input: $input"); }

Replies are listed 'Best First'.
Re: Writing to a Pipe
by ikegami (Patriarch) on Jun 21, 2007 at 01:12 UTC
    You are suffering from buffering. You also have at least two precedence bugs in the conditionals in your first statement.
    use IO::Handle; if (!open(TPOOL, "|thread_pool.test)) { print "error: $!"; exit(1); } TPOOL->autoflush(1); while(1) { sleep 10; print TPOOL "This is just a test\n"; }
      Dude. Your advice was right on thanks a lot. Craig