in reply to Re: colored output
in thread colored output

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.

Replies are listed 'Best First'.
Re^3: colored output
by belden (Friar) on Jan 03, 2005 at 23:59 UTC
    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; }; }

Re^3: colored output
by JamesNC (Chaplain) on Jan 05, 2005 at 04:07 UTC
    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.