On Tue, Jul 29, 2003 at 01:29:32PM +0200, Stefan Svensson wrote:
> I'd like to capture everything that is written to STDERR and process it 
> within POE. Is this possible (except from being dangerous)?

Term::Visual does this.  It redirects STDERR messages into its terminal
window, first giving them some color.

  ### Redirect STDERR into the terminal buffer.
  use Symbol qw(gensym);

  # Pipe STDERR to a readable handle.
  my $read_stderr = gensym();

  pipe($read_stderr, STDERR) or do
  { open STDERR, ">&=2";
    die "can't pipe STDERR: $!";
  };

  $heap->{stderr_reader} = POE::Wheel::ReadWrite->new
    ( Handle      => $read_stderr,
      Filter      => POE::Filter::Line->new(),
      Driver      => POE::Driver::SysRW->new(),
      InputEvent  => "got_stderr",
    );

And you get "got_stderr" events when something occurs on STDERR.

-- 
Rocco Caputo - [EMAIL PROTECTED] - http://poe.perl.org/

Reply via email to