in reply to colored output

Term::ANSIColor does that.
Boris

Replies are listed 'Best First'.
Re^2: colored output
by florg (Friar) on Jan 02, 2005 at 13:51 UTC
    Adding to that, there are some nice examples of Term::ANSIColor in the 2004 Advent Calendar: 2nd.
Re^2: colored output
by ikegami (Patriarch) on Jan 02, 2005 at 21:24 UTC
    In Windows, you'll need to load up Win32::Console::ANSI in addition to Term::ANSIColor, since Windows doesn't naturally interpret ANSI console escape sequences. I'd add use if $^O eq 'MSWin32', 'Win32::Console::ANSI'; if I wanted portability.
      That assumes perl 5.6.2 or higher. A more portable solution might be:
      # check whether if.pm is available eval { use if 1, 'if' } ; my $has_if = defined $@ ; if ( $has_if ) { use if $^0 eq 'MSWin32', 'Win32::Console::ANSI' ; } elsif ( $^O eq 'MSWin32' ) { eval { use Win32::Console::ANSI } ; die "$@, stopped" if $@ ; }
      </facetiousness>

        Good catch, thanks.

        In this case, it's probably sufficient to use only BEGIN { eval { require Win32::Console::ANSI; }; }

      I would only add ( from Win32::Console::ANSI perldoc )
      Windows NT/2000/XP does not support ANSI escape sequences in Win32 Con +sole applications. This module emulates an ANSI console for the script which uses it.
      Update: This indeed does work under Win2K and AS 5.8 Perl and gellyfish proved it to me. I had previously used PPM to download this and then ran the example with NO luck. gellyfish sent me a screenshot proving otherwise, so I downloaded and built this module which worked as advertised! I will be very careful about just assuming that any module installed via PPM is guaranteed to work.