Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How to get a Color Display

Reply
Thread Tools

How to get a Color Display

 
 
George Kinley
Guest
Posts: n/a
 
      05-18-2004
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


 
Reply With Quote
 
 
 
 
Thomas Kratz
Guest
Posts: n/a
 
      05-18-2004
George Kinley wrote:

> 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

--
open STDIN,"<&DATA";$=+=14;$%=50;while($_=(seek( #J~.> a>n~>>e~.......>r.
STDIN,$:*$=+$,+$%,0),getc)){/\./&&last;/\w| /&&( #.u.t.^..oP..r.>h>a~.e..
print,$_=$~);/~/&&++$:;/\^/&&--$:;/>/&&++$,;/</ #.>s^~h<t< ..~. ...c.^..
&&--$,;$:%=4;$,%=23;$~=$_;++$i==1?++$,:_;}__END__#.... >>e>r^..>l^...>k^..
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Not able to display color in excel not able to display color in excel using xml sed_y XML 0 02-15-2012 09:46 PM
Changing font color from current font color to black color Kamaljeet Saini Ruby 0 02-13-2009 04:58 PM
how to convert color in style "#e6e6e6" to color object in vb.net moondaddy ASP .Net 3 04-28-2004 04:59 AM
Cannot get display on computer to display anything Powerbook Computer Support 5 02-26-2004 12:30 AM



Advertisments