problem solved. POE::Wheel::ReadWrite->new should be put in _start event.
George "George Chung" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > I want the following code to read and write from STDIN and to STDOUT. > It's supposed to work if I type "echo test|./poe_test.pl". However the > problem > seems looping forever and eats all CPU time. It seems it cannot get data > from STDIN. > > Could anyone tell me what the problem is in the code? > > Thank you. > > George > > =============== code of poe_test.pl ======== > #!/usr/bin/perl > > use POE qw(Filter::Line Wheel::ReadWrite); > > sub handle_input{ > > my ($heap, $input, $wheel_id) = @_[HEAP, ARG0, ARG1]; > > open(FH,">>/tmp/cc"); > print FH $input,"\n"; > close(FH); > exit; > } > > $wheel = POE::Wheel::ReadWrite->new > ( InputHandle => \*STDIN, > OutputHandle => \*STDOUT, > InputEvent => "event_input", > Filter => POE::Filter::Line->new() > ); > > > POE::Session->create( > inline_states => { > _start => sub {}, > _stop => sub {}, > event_input => \&handle_input, > event_sigchld => \&handle_sigchld, > } > ); > > $|=1; > $poe_kernel->run(); > exit 0; > > >
