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):
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?
#!/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?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: making a spinner
by blakem (Monsignor) on Sep 20, 2001 at 22:40 UTC | |
Re: making a spinner
by shotgunefx (Parson) on Sep 20, 2001 at 22:29 UTC | |
Re: making a spinner
by phubuh (Beadle) on Sep 20, 2001 at 22:54 UTC | |
Re: making a spinner
by archen (Pilgrim) on Sep 20, 2001 at 23:17 UTC | |
by boo_radley (Parson) on Sep 20, 2001 at 23:31 UTC | |
Re: making a spinner
by perlisfun (Sexton) on Sep 21, 2001 at 01:05 UTC | |
Re: making a spinner
by demerphq (Chancellor) on Sep 22, 2001 at 20:44 UTC | |
Re: making a spinner
by grummerX (Pilgrim) on Sep 21, 2001 at 17:58 UTC | |
Re: making a spinner
by snafu (Chaplain) on Sep 21, 2001 at 17:45 UTC |
Back to
Seekers of Perl Wisdom