use Tie::Cycle; my $delay=5; tie my $spinner, 'Tie::Cycle', [map {("\b$_")x$delay}qw(\ | / -)]; print $spinner while (1);