in reply to color STERR red?

How do you launch them?

If you do it with require or do, the IO layers mentioned in the replies above will work.

If you launch them as separate processes (system, fork + exec, backticks) then you'll have to capture STDERR, color it and re-emit it.

For that you might want to use something like IPC::Run with a callback for handling STDERR:

use Term::ANSIColor; sub handle_err { print STDERR color('red'), @_; } use IPC::Run; run ['yourprogram', 'argument'], \*STDOUT, \&handle_err;

Replies are listed 'Best First'.
Re^2: color STERR red?
by Tux (Canon) on May 09, 2011 at 06:31 UTC

    That works unless STDOUT uses the same stream as STDERR, in which case all printed code after the STDERR prints are also red.

    You should use

    print STDERR color ("red"), @_, color ("reset");

    or use the colored ("red", string) approach.

    If you need more than just colors, like indents or modification, you can use Text::OutputFilter as an alternative:

    use strict; use warnings; use Text::OutputFilter; use Term::ANSIColor; tie *STDERR, "Text::OutputFilter", 0, *STDERR, sub { color ("red")."$_[0]".color ("reset") }; print STDOUT "Normal\n"; print STDERR "Red?\n"; print STDOUT "Normal again?\n";

    Enjoy, Have FUN! H.Merijn
      Thank you all, lots of great suggestions! /me ponders...