I am using the following code to start a perl script using Wheel::Run (io.pl, at end of post) which simply sends a couple of messages to stdout, then echos stdin to stdout, and eventually exits after 10 writes.
When i run the following perl script it works fine until i get the child closed event. I then get a windows error with the perl interpeter. ######################################################################################## # run.pl ######################################################################################## #!/usr/bin/perl use warnings; use strict; use Tk; use POE qw( Wheel::Run Filter::Line ); # Start the session. Spawn a simple program, and describe the events # it will generate as it does things. POE::Session->create ( inline_states => { _start => \&_start, got_child_stdout => \&got_child_stdout, got_child_stderr => \&got_child_stderr, got_child_close => \&got_child_close, write_io => \&write_io, } ); # Run the program until it is exited. $poe_kernel->run(); print "Exiting app...\n"; exit (0); sub _start { #my ( $kernel, $heap ) = @_[ KERNEL, HEAP ]; my ( $kernel, $session, $heap ) = @_[ KERNEL, SESSION, HEAP ]; #$heap->{counter_widget} = $poe_main_window->Label( -textvariable => \$heap->{counter} )->pack; $poe_main_window->Button ( -text => "Write", -command => $session->postback("write_io") )->pack; $heap->{text} = $poe_main_window->Text()->pack(-expand => '1', - fill => 'both'); $poe_main_window->update; $heap->{child} = POE::Wheel::Run->new ( Program => [ "perl io.pl", ], # Program to run. StdioFilter => POE::Filter::Line->new(), # Child speaks in lines. StderrFilter => POE::Filter::Line->new(), # Child speaks in lines. StdoutEvent => "got_child_stdout", # Child wrote to STDOUT. StderrEvent => "got_child_stderr", # Child wrote to STDERR. CloseEvent => "got_child_close", # Child stopped writing. ); } # Deal with information the child wrote to its STDOUT. sub got_child_stdout { my $heap = $_[HEAP]; my $stdout = $_[ARG0]; print "STDOUT: $stdout\n"; my $text = $heap->{text}; $text->insert('end', "$stdout\n"); $text->see('end'); #if ($stdout =~ /^Starting/) { &write_io; } #if ($stdout =~ /^007/) { &write_io; } } # Deal with information the child wrote to its STDERR. These are # warnings and possibly error messages. sub got_child_stderr { my $stderr = $_[ARG0]; $stderr =~ tr[ -~][]cd; print "STDERR: $stderr\n"; } # The child has closed its output filehandles. It will not be sending # us any more information, so destroy it. sub got_child_close { my $heap = $_[HEAP]; print "child closed.\n"; delete $heap->{child}; } # A list of functions that will handle the events they're named after. my @handlers = qw( _start got_child_stdout got_child_stderr got_child_close write_io ); # Start a session where each event is handled by a function with the # same name. Run POE's Kernel (and thus all its sessions) until done. sub write_io { my $heap = $_[HEAP]; my $wheel = $heap->{child}; print "Starting to Write to Object [$wheel]...\n"; print "W[$wheel]\n"; $wheel->put("Hi There"); #for (my $i=0; $i<4; $i++) { print "W[$wheel]\n"; $wheel->put("Hi There [$i]"); } } ######################################################################################## # io.pl ######################################################################################## select STDIN; $|++; select STDOUT; $|++; my $cnt=0; print "Starting...\n"; while ($cnt < 5) { printf ("%03d %s\n", $cnt++, "This is a test!"); sleep 1; } while (<>) { chomp; printf ("%03d %s\n", $cnt++, $_); if ($cnt > 10) { print "Goodbye!!!\n"; last; } } print "Ending...\n";