in reply to Way of the Spinner (repost)
A slight variation. Use a string and substr rather than an array. I also use a backspace rather than \r so that you can hang the spinner on the end of a line with out having to reprint the whole line each time. Stops the whole line flickering.
#! perl -sw use strict; $|++; sub spinner{ my ($s, $n) = (shift,0); return sub{ substr( $s, $n++ % length $s,1) . "\cH"; } } my $spinner = spinner '-\|/'; print "Working "; print $spinner->() for 1 .. 10000;
Examine what is said, not who speaks.
The 7th Rule of perl club is -- pearl clubs are easily damaged. Use a diamond club instead.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Way of the Spinner (repost)
by Aristotle (Chancellor) on Jan 18, 2003 at 16:52 UTC | |
|
Re: Re: Way of the Spinner (repost)
by demerphq (Chancellor) on Jan 20, 2003 at 16:02 UTC |