<?xml version="1.0" encoding="windows-1252"?>
<node id="5913" title="RE: A whirleygig for a progress indicator for scripts" created="2000-03-22 19:13:02" updated="2005-08-11 14:15:55">
<type id="11">
note</type>
<author id="2675">
btrott</author>
<data>
<field name="doctext">
In that spirit, here's another idea for improving/generalizing
your code.

&lt;code&gt;
    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-&gt;(), "\r";
    }
&lt;/code&gt;

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.</field>
<field name="root_node">
4943</field>
<field name="parent_node">
4943</field>
</data>
</node>
