in reply to "a bit of sugar "(HOP)

I only see one definition of Iterator in your code - and it's outcommented. Essentially, "Iterator" is a noop, but because Perl allows you to leave off the 'sub' keyword if the first argument of a subroutine has prototype '&' (as here), the code is allowed to write:
return Iterator {BLOCK}
instead of
return sub {BLOCK}

Replies are listed 'Best First'.
Re^2: "a bit of sugar "(HOP)
by Wiggins (Hermit) on Mar 13, 2009 at 18:15 UTC
    Iterator appears twice. The first where you found it. The second is 6 lines below, in a "return Iterator { ..... } line that is the actual code reference of the iterator. This is the confusing part...

    It is always better to have seen your target for yourself, rather than depend upon someone else's description.

      The syntactic sugar is in the fact that the & prototype allows you to write return Iterator {...} instead of return Iterator sub {...}

        Yes, (&) is syntactic sugar, but that doesn't explain Iterator.

        I see is as return Iterator {...} being semantic sugar for return sub {...}. It signals to the reader that the closure is an iterator.

      The string Iterator indeed appears twice. But an appearance isn't a definition. There's only one definition of Iterator in the code - and that's outcommented.