in reply to using colors with print()

In what context - terminal, GUI, CGI, printer? On what OS? How you do it depends on these factors. Color::Output or Curses::UI::Color may be what you are looking for but who knows? We need more information to point you in the right direction.

cheers

tachyon

Replies are listed 'Best First'.
Re^2: using colors with print()
by drwxrwxrwx (Novice) on Jun 19, 2004 at 12:25 UTC
    ok i apologize i'm using print() on a terminal (linux)
      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.