How to get a Color Display

Discussion in 'Perl Misc' started by George Kinley, May 18, 2004.

  1. 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
     
    George Kinley, May 18, 2004
    #1
    1. Advertising

  2. George Kinley

    Thomas Kratz Guest

    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^..
     
    Thomas Kratz, May 18, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. moondaddy
    Replies:
    3
    Views:
    38,504
    moondaddy
    Apr 28, 2004
  2. PJ6
    Replies:
    4
    Views:
    4,903
  3. Andrew Arace

    BGR Color to Java Color

    Andrew Arace, Sep 13, 2003, in forum: Java
    Replies:
    7
    Views:
    7,848
    Stephen Gilbert
    Sep 16, 2003
  4. Kamaljeet Saini
    Replies:
    0
    Views:
    445
    Kamaljeet Saini
    Feb 13, 2009
  5. sed_y
    Replies:
    0
    Views:
    1,035
    sed_y
    Feb 15, 2012
Loading...

Share This Page