in reply to Re: using colors with print()
in thread using colors with print()

ok i apologize i'm using print() on a terminal (linux)

Replies are listed 'Best First'.
Re^3: using colors with print()
by tachyon (Chancellor) on Jun 19, 2004 at 12:43 UTC
    Term::ANSIColor will do what you want in the easiest possible way. The docs and source explain how printing ANSI escape sequences causes your terminal to do (color) stuff
    $cat color.pl
    #!/usr/bin/perl
    use Term::ANSIColor qw(:constants);
    print BOLD, BLUE, "This text is in bold blue.\n", RESET;
    print RED, "This text is red.\n", RESET;
    
    $ ./color.pl
    This text is in bold blue.
    This text is red.
    $
    

    To set the AUTORESET feature so you can loose the RESET tokens set $Term::ANSIColor::AUTORESET = 1 just after the use. RTFS to see the available constants. Don't use BLINK :o)

    cheers

    tachyon

    A reply falls below the community's threshold of quality. You may see it by logging in.