Howdy Monks. I am trying to make a little text mode spinner that will indicate that a script is running. Somehow I can't get the ANSIScreen mod to work properly. The code follows. When I run it, it waits till the script is done then prints out the intended chars with the escape codes embedded, rather than taking them as escape codes. I'm running it on Win32. What am I doing wrong?
TIA....
Steve
use strict; use Win32::Console::ANSI; # thanks ikegami $|=1; # turn off output buffering. thanks Tanktalus use Term::ANSIScreen qw/:screen :cursor/; our @spinchars = qw( / - \ | ); our $spinvalue = 0; for my $i (0..10) { spinner(); sleep 1; } $|=0; # restore output buffering sub spinner { print left(1)."$spinchars[$spinvalue]"; $spinvalue++; if ($spinvalue > 3) { $spinvalue = 0; } return; }
UPDATE:
With suggested chantes it works now except that the cursor flashes next to the spinner in an undesirable way. I tried to turn it off with
my $console = Term::ANSIScreen->new; $console->Cursor(-1,-1,-1,-1,0);
As it seemed might work based on the Term::ANSIScreen docs. Alas something is not working right as the cursor doesn't shut off.
Formatting fixed by GrandFather
2006-06-28 Retitled by GrandFather, as per Monastery guidelines
Original title: 'ANSIScreen progress spinner'
In reply to Term::ANSIScreen Won't Work by cormanaz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |