in reply to Way of the Spinner (repost)

Everyone seem to have focused so much on making a thing spinn, that they haven't discovered the bug in your code. Take this as a good thing. ;)

Anyhow, the bug is that @_ always is defined in your subroutine. (The exception would be if someone called it with &spinner; from a place where @_ wasn't defined.) That in its turn makes @chars stay empty if called without arguments, resulting in a modulus by zero error in the closure.

There's also another issue with the closure, and that is that it quotes its return value. There's absolutely no reason for that. In fact, if spinner was abused to hold objects then it would break. Do not quote when you don't need to!

In the spirit of TMTOWTDI; the closure can be rewritten to   sub { push @chars, shift @chars; $chars[0] } Not that I recommend that. :)

ihb