How to get a Color Display

G

George Kinley

Hi,
I am using/working on Win2K, I run my scripts on cmd.exe ,
I want to change attributes of my print statements in color ,

If I use code from perlfaq8.pod

use Term::ANSIColor;
print color("red"), "Stop!\n", color("reset");
print color("green"), "Go!\n", color("reset");


The output I get is

?[31mStop!
?[0m?[32mGo!
?[0m

I have gut feeling its a basic query , but what is wrong
-g
 
T

Thomas Kratz

George said:
Hi,
I am using/working on Win2K, I run my scripts on cmd.exe ,
I want to change attributes of my print statements in color ,

If I use code from perlfaq8.pod

use Term::ANSIColor;
print color("red"), "Stop!\n", color("reset");
print color("green"), "Go!\n", color("reset");


The output I get is

?[31mStop!
?[0m?[32mGo!
?[0m

I have gut feeling its a basic query , but what is wrong

Your command interpreter (cmd.exe) needs to have ansi.sys loaded (just
like under plain old DOS). I haven't used it myself, but I would assume
you have to put a line

device=%SYSTEMROOT%\SYSTEM32\ansi.sys

into your config.sys. Alas this is a bummer if you want to transfer the
script to other machines.

Alternatively you can use Win32::Console from the libwin32 package
available on CPAN (you'll already have that if you use ActivePerl).
This works out of the box.

Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top