in reply to A whirleygig for a progress indicator for scripts
In that spirit, here's another idea for improving/generalizing
your code.
This packages up your whirley functionality into a package and a closure--you could even put it into Whirley.pm or something; then just use it and call it as illustrated.package Whirley; sub new { my $type = shift; my $class = ref $type || $type; my $WHIRLEY_COUNT = -1; my @whirley = map chr, qw/32 176 177 178 219 178 177 176/; my $self = sub { $WHIRLEY_COUNT = 0 if ++$WHIRLEY_COUNT == @whirley; return $whirley[$WHIRLEY_COUNT]; }; bless $self, $class; } package main; my $whirley = new Whirley; while (1) { sleep 1; print STDERR "please wait: ", $whirley->(), "\r"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: RE: A whirleygig for a progress indicator for scripts
by synistar (Pilgrim) on Dec 08, 2003 at 22:15 UTC | |
by Wire64 (Initiate) on May 16, 2009 at 17:42 UTC | |
by Corion (Patriarch) on May 16, 2009 at 17:50 UTC |
In Section
Cool Uses for Perl