in reply to Spining "stick"

What you are looking for may also be referred to as whirleygigs or spinners. One node I do recall on the topic was spinner to keep the patiently waiting user patient, which I recall also may have included a few links to several other nodes on the topic.

Hope that helps.

Replies are listed 'Best First'.
Re^2: Spining "stick"
by tachyon (Chancellor) on Jul 03, 2004 at 11:37 UTC

    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

      This was producing no output on my system, unless I commented out the select line. Replacing select with a sleep also produced no output. But I worked it out, by adding a line saying local $| = 1; to the start of the program, I got output.