in reply to Twirling baton progress indicator in Perl

It works for me and gives the output shown below. (I modified your code slightly so the loop would terminate and to avoid using switch.)

use strict; use warnings; my $intervals = 20; my $interval = 1; # Sleep time between twirls my $tcount = 0; # For each tcount the line twirls one increment while ($intervals-- > 0) { $tcount++; print "$tcount\n"; if ($tcount == 1) { printf '-'; sleep $interval; } elsif ($tcount == 2) { print "\\"; sleep $interval; } elsif ($tcount == 3) { print "|"; sleep $interval; } elsif ($tcount == 4) { print "/"; sleep $interval; } else { $tcount = 0; } }
1 -2 \3 |4 /5 1 -2 \3 |4 /5 1 -2 \3 |4 /5 1 -2 \3 |4 /5

Perl is Huffman encoded by design.