in reply to Pipeing to a Tk-App

After you do this:
open(VIRTUALPRN, "| perl print.pl");
... and before you do this:
print VIRTUALPRN "foobar\n"
you could try this:
select VIRTUALPRN; # make this the "default" output handle $|++; # disable output buffering on this handle
Or, more elegantly:
use FileHandle; ... my $VirtualPrnFH = new FileHandle; $VirtualPrnFH->open( "| perl print.pl" ); $VirtualPrnFH->autoflush(1); # turn off buffering ... print $VirtualPrnFH "foobar\n"; ...
If you're only writing a small amount of content to that process, the default buffering would withhold output to the process until the file handle closes, which you could do explicitely in the parent process (rather than just exiting), but it's better to turn off buffering.

Replies are listed 'Best First'.
Re: Re: Pipeing to a Tk-App
by schweini (Friar) on Feb 17, 2003 at 05:56 UTC
    yep.
    that did the trick. i forgot to select VIRTUALPRN before doing the $|++.
    silly me.
    Thanks a lot!