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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.