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?
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link or
or How to display code and escape characters
are good places to start.
|