What you describe is recursive, not iterative. It won't work because as you noted $anon is not defined until the end of the statement, and as far as I know a subroutine can not be a closure on itself. Perhaps if you explained why you're attempting such an odd thing, we could provide a better way to do it.