By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,835 Members | 2,333 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,835 IT Pros & Developers. It's quick & easy.

Changing text color of windows command propmpt through PERL

P: 23
Dear All,

I am writting a PERL script in windows to test some test cases. The test result is captured both in command prompt and in the log file. But when the result is displayed on a windows command prompt, its very difficult to read the output text. Instead I was thinking of changing the text color of the command prompt. I mean if the test case passes...then the result will be displayed in Green color and in case of any errors/failures, display it in a red color.

I did some googling and found the following link which will explain how to change text color in windows. But i was wondering how do i do it through perl script to display only selected text messages in a particular color?

http://www.computerhope.com/color.htm

Please let me know if anyone knows about it.
Thanks

Pramod
Jun 16 '08 #1
Share this Question
Share on Google+
1 Reply


P: 23
Here is the answer :

Expand|Select|Wrap|Line Numbers
  1. use Win32::Console::ANSI;
  2. use Term::ANSIScreen qw/:color /;
  3.  
  4. print colored ("This text is bold green.\n", 'bold green');
  5. print "This text is normal.\n";
  6. print colored ['bold red'], "This text is bold red.\n";
  7. print "This text is normal.\n";  
Thanks to meloyelo :-)
Jun 17 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.