On 27/05/10 22:16 -0500, Bryan Harris wrote:
   my $e = "\033[0m";
   my %cc = (
       white => "\033[1;37m",
       ltgray => "\033[0;37m",
       gray => "\033[1;30m",
       black => "\033[0;30m",
       red => "\033[0;31m",
       ltred => "\033[1;31m",
       green => "\033[0;32m",
       ltgreen => "\033[1;32m",
       brown => "\033[0;33m",
       yellow => "\033[1;33m",
       blue => "\033[0;34m",
       ltblue => "\033[1;34m",
       purple => "\033[0;35m",
       pink => "\033[1;35m",
       cyan => "\033[0;36m",
       ltcyan => "\033[1;36m",
   );

   print $cc{red}, "This is red text.\n", $e;

And if you want to work with 256 colors (note that not all terminals support
this, and it should be avoided if it's not for your own use) you can do
something like this:


my @colors;
for(my $i=0;$i<256;$i++) {
  push(@colors, "\033[38;5;$i".'m');
}
print "$colors[100] This is olive green text \033[0m\n";


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to