http://qs321.pair.com?node_id=113661

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

Actually this is sort of related to a question I saw earlier about reporting the status of something being done. One thing I always sort of wanted to do is make a spinner. By spinner I mean a simple section of text which changes from | to / to - to \ . While I was booting Free BSD and watching one, I thought about how something like this could enhance my programs, and at least show that they're still working (and not hanging) - this became especially apperent today when I wrote an encryption program that takes a LONG time. If I could somehow show something happening around every 100th iteration of the main loop, I could at least show that it is doing something. But here's the catch, I want it to work in both Unix AND Windows. I know Term has the functionality I need, but it doesn't support Windows. About the only thing I could come up with was the following (this is just example code):

#!/usr/bin/perl my $spinner; my @spinState = ("-", "\\", "|", "/"); foreach(1..25) { print "Working: " . $spinState[$spinner] . "\n"; print " \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"; sleep(1); }

And as you can see that's basically a pile of slop and not any real sort of solution. Actually just being able to overwrite the last character written to the screen is all I need. Any Ideas?