blackadder has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks

I have the following code;
#!c:/perl/bin/perl.exe -w use strict; use vars qw/%data/; use Win32; use Win32::Console::ANSI; use Term::ANSIColor; $data{colors} = { 1 => 'bold blue', 2 => 'bold blink yellow', 3 => 'blink red', 4 => 'blink white', 5 => 'blink green', 6 => 'blink cyan', 7 => 'rapid blink magenta', 8 => 'blink grey', }; print "\n"; for (1..100) { print colored ("*",$data{colors}{(rand(100)%6)+1}); } print "\n";
The blink doesn't seem to work, not sure if this is how it should be coded, there were no examples in the module documentation on how to set the blinking.

Can a holy creature helps out with this please?

Thanks
Blackadder

Replies are listed 'Best First'.
Re: Blinking Win32::Console::ANSI
by simon.proctor (Vicar) on Oct 08, 2004 at 11:33 UTC
    I wrote this while eating so if it doesn't do what you want blame the pickle :)
    use strict; use Win32; use Win32::Console::ANSI; use Term::ANSIColor; my $data = { 1 => 'bold blue', 2 => 'bold blink yellow', 3 => 'blink red', 4 => 'blink white', 5 => 'blink green', 6 => 'blink cyan', 7 => 'rapid blink magenta', 8 => 'blink grey', }; print "\n"; for (1..100) { print colored ("*",$data->{(rand(100)%6)+1}); print "\r"; sleep(1); }
    All I did was change your hash bit and add the sleep. To make it blink in place I printed a used the \r.

    Update: Just to note that I kept the hash as I didn't know if you wanted to use that as a larger configuration variable (ie for more than just colours) outside this example code. If its just for these colours and nothing more then you can use an array and probably should. HTH
      Lets just blame it on the pickle.
      Blackadder
Re: Blinking Win32::Console::ANSI
by Albannach (Monsignor) on Oct 08, 2004 at 14:07 UTC
    It looks like you're out of luck. The Term::ANSIColor docs note that blink is often not available depending on your terminal. The Win32::Console::ANSI which is trying to emulate terminal handling for your Win32 console, notes that blink mode is not implemented. In the old days we'd use ANSI.SYS (or a better clone) to do decent ANSI/VT100 escape sequence control, but that isn't an option under Win2k/XP's CMS.EXE it would seem.

    Perhaps you can find a better Win32 console shell?

    --
    I'd like to be able to assign to an luser

      Oh well, it would've been my first JAPH obfuscation,...in color.

      That was the intention.

      Many Thanks.