in reply to Executing pipe STDOUT from a subroutine to Widget

#!/usr/bin/perl -w use strict; use Tk; use Tk::Text; use Tk::IO; my $mw = MainWindow->new( -width => 200, -height => 200); my $textwidget = $mw->Text()->pack( -expand => 1, -fill => 'both'); tie *STDOUT, ref $textwidget, $textwidget; my $label = $mw->Label( -text => ".")->pack( -fill => 'x'); my $b = $mw->Button( -text => "start", -command => \&start)->pack( -fi +ll => 'x'); ## just showing that Tk events are actually handled all the time my $i = 0; my @thing = qw( . o O o ); $mw->repeat( 100 => sub { $label->configure( -text => $thing[$i++] x 2 +0); $i = 0 if $i == @thing }); sub start { # this catches the output of the child process and # sends it to (tied) STDOUT of this process my $io = Tk::IO->new( -linecommand => sub { print @_ }, -childcomman +d => sub { print "EOF\n" } ); $io->exec(q(perl -e '$|=1; for (0 .. 10) { print "$_\n"; sleep 1 }') +); } MainLoop;

Replies are listed 'Best First'.
Re^2: Executing pipe STDOUT from a subroutine to Widget
by Anonymous Monk on May 15, 2008 at 12:28 UTC
    '-' is not recognized as an internal or external command, operable program or batch file.
    perlport says open to |- and -| are unsupported. (Mac OS, Win32, RISC OS)