in reply to Iterative anonymous subroutines

You can also solve this problem using a combination of a fixed point combinator (don't worry it's not as complex as it sounds) and currying.

Basically your problem is that you have a un-nameable subroutine which you want to recurse with. The problem is you are trying to call your subroutine by name, which is not possible since it's name can never be in the proper scope. The other option then is to call-by-value instead. In order to accomplish this, all you need to do is alter your anon-subroutine to take an additional parameter, which is the function you wish to call in the recursion. It might look something like this:

my $anon = sub { my $func = shift; my $count = shift; if ($count--) { print "Iterating\n"; $func->($count); } };
Now when you want to call this sub, you have to pass the sub itself as it's first parameter, and now you have your recursion.

Of course, this is most likely inconvient to have to do this. Fear not! Currying to the rescue! Just do this:

my $counter = sub { $anon->($anon, shift) };
And return $counter instead of $anon, and you have exactly what you are looking for.

Hope this helps :)

-stvn