Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: A whirleygig for a progress indicator for scripts

by Shendal (Hermit)
on Sep 21, 2001 at 00:53 UTC ( #113699=note: print w/ replies, xml ) Need Help??


in reply to A whirleygig for a progress indicator for scripts

In the spirit of TMTOWTDI, I thought that using tie might be interesting.

##### Whirley package package Whirley; use strict; my @whirlies = qw!. o 0 O 0 o!; my $current = -1; sub TIESCALAR { my $type = shift; my $class = ref $type || $type; my $self = {}; bless $self, $class; } sub FETCH { my $self = shift; my $backspace = $current < 0 ? '' : "\b"; # don't backspace on first + go 'round $current = 0 if (++$current == @whirlies); return $backspace . $whirlies[$current]; } ##### Main package package Main; use strict; $|++; my $whirley; tie $whirley, 'Whirley'; print "Please wait: "; while (1) { print $whirley; sleep 1; }

Cheers,
Shendal


Comment on Re: A whirleygig for a progress indicator for scripts
Download Code
Re: Re: A whirleygig for a progress indicator for scripts
by rob_au (Abbot) on Dec 18, 2002 at 12:53 UTC
    Using the Tie::Cycle module, this can be simplified further ...

    use Tie::Cycle; tie my $whirley, 'Tie::Cycle', [ qw( . o 0 O 0 o ) ]; # And now for the demonstration ... ++$|; while (1) { print $whirley, "\b"; sleep 1; }

     

    perl -le 'print+unpack("N",pack("B32","00000000000000000000001000000000"))'

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://113699]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (11)
As of 2014-10-31 10:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (216 votes), past polls