neocytrix Posted April 3, 2004 Report Share Posted April 3, 2004 Hello again, I was wondering if there are any perl programmers out there that would know how to make text a different color. Example print "this is a test"; How would I make the words "this is a test" a different color? Is there a way? -Neocytrix Quote Link to comment Share on other sites More sharing options...
aru Posted April 3, 2004 Report Share Posted April 3, 2004 I'm not a perl programmer, but I know that the syntax is very similar to bash. To print text in red color do: ~$ cat colors.pl #! /usr/bin/perl # shows output in red $red="\e[1;31m"; $normal="\e[0m\n"; print "$red This is a text $normal"; Some time ago I wrote this function for my own bash library, so you may use it to find out which are the strings that define each color: : # listado de colores terminal. colores () { normal="\\033[0;39m"; for j in 0 1; do for i in $(seq 30 36) $(seq 43 47); do color="\\033[${j};${i}m"; echo -ne "${color}\\\\\\${color}"; echo -e "$normal"; done; done; echo -ne "\n${normal}\\\\\\${normal} NORMAL\n" } colores Copy the above text into a file and run it, it will show you the different keys for each color. Then you'll only need to translate them into perl format. HTH Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.