It is a good use for carriage return and select to get a sub 1 sec sleep. A variation on this is wget style progress bar if that is more approptriate to the task at hand ie you know how far you are through the task.
while( $waiting or 1 ) { spin(); } { my $c=0; # closure to remember spin state sub spin { local $| = 1; print "\r", qw( | / - \ )[$c++%4]; select undef, undef, undef, 0.25; # sleep 250 msec } }
Unbuffered output as per beebles note.
cheers
tachyon
In reply to Re^2: Spining "stick"
by tachyon
in thread Spining "stick"
by chiburashka
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |