I am looking for an example using Wheel::Run within a child process. I need
to know how to read the output of a Wheel after using put. I'm not sure i'm
doing it right (pardon my ignorance i'm new to POE). For some reason either
the program that I wrote that Wheel::Run calls is not taking input/output
correctly or I am just plain missing something. I am using the same info
from the docs. Here is a snippet of the code:

sub child_start {
  my ($kernel, $session, $parent, $heap, $email) = @_[KERNEL, SESSION,
SENDER, HEAP, ARG0];

  # Remember the parent.
  $heap->{parent} = $parent;

  warn "Child ", $session->ID, " will validate $email.\n";

  # Check the passed email address.

  my $program = [ "./check_addr.pl" ];
  my $wheel = POE::Wheel::Run->new(
                  Program    => $program,
                  StdoutEvent => &stdout, # Event to emit with child stdout
information.
                  Filter => POE::Filter::Line->new(), # Or some other
filter.
                  );
   $wheel->put($email);
}

# The child has finished whatever it was supposed to do.  Send the
# result of its labor back to the parent.
sub stdout {
  my ($heap, $input, $wheel_id) = @_[HEAP, ARG0, ARG1];
  print "Child process in wheel $wheel_id wrote to STDOUT: $input\n";

  # Post the result back to the parent.  The child has nothing left to
  # do, and so it stops.
  #$kernel->post($heap->{parent}, 'result', $email, $result);
}

sub stderr {
  my ($heap, $input, $wheel_id) = @_[HEAP, ARG0, ARG1];
  print "Child process in wheel $wheel_id wrote to STDERR: $input\n";

  # Post the result back to the parent.  The child has nothing left to
  # do, and so it stops.
  #$kernel->post($heap->{parent}, 'result', $email, $result);
}

And the check_addr.pl program simply looks like this
#!/usr/bin/perl
my $email = <>;
chomp($email);
print 1;

It doesn't seem to ever be able to read the data that check_addr sends back.
Should I be doing this another way?

-Ryan

Reply via email to