On Thu, Mar 14, 2002 at 01:45:28AM -0800, Ryan White wrote:
> 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);
> }

I see two problems here:

First, you are not storing the new POE::Wheel::Run instance in $heap,
so it's destructing as soon as child_start() returns.

Second, your StdoutEvent should be an event name, not a code
reference.

[...]

> 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?

POE::Wheel::Run expects to receive lines of data.  You may need to add
a newline to your print() statement.

-- Rocco Caputo / [EMAIL PROTECTED] / poe.perl.org / poe.sf.net

Reply via email to