<?xml version="1.0" encoding="windows-1252"?>
<node id="4943" title="A whirleygig for a progress indicator for scripts" created="2000-03-06 18:08:10" updated="2005-08-03 11:09:27">
<type id="1980">
snippet</type>
<author id="1506">
da w00t</author>
<data>
<field name="doctext">
</field>
<field name="snippetdesc">
Lets say you have a perl script sucking rows out of a database.  You generally want to know that it's still running, instead of it sitting there, working it's butt off, and not printing anything while it performs some math or hashing or something.  This whirleygig prints a character to stdout or stderr so you can see it working.</field>
<field name="snippetcode">
&lt;CODE&gt;
#!/usr/bin/perl

$|=1;$WHIRLEY_COUNT=-1;

#$whirley='-\|/';@whirley=split //,$whirley;
#$whirley='.o0O0o';@whirley=split //,$whirley;
#$whirley='1234567890';@whirley=split //,$whirley;
#$whirley='';@whirley=split //,$whirley;
$whirley=" ".pack(C,176).pack(C,177).pack(C,178).pack(C,219).pack(C,178).pack(C,177). pack(C,176);@whirley=split //,$whirley;


sub whirley {
  if ($WHIRLEY_COUNT+1==@whirley) {
    $WHIRLEY_COUNT=0;
  } else {
    $WHIRLEY_COUNT++;
  }
  return "@whirley[$WHIRLEY_COUNT]";
}

while (1) {
    sleep 1;
    print STDERR "please wait : ".&amp;whirley."\r";
}
&lt;/CODE&gt;</field>
</data>
</node>
