in reply to understanding closures

The purists might not call it a closure, but it operates under the same principle. In your second example, counter() makes a reference to $count, a lexical in the scope of the function. It's the same principle, just without the indirection of a function reference.

Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

Replies are listed 'Best First'.
Re^2: understanding closures
by jdporter (Paladin) on Sep 23, 2005 at 20:30 UTC
    Actually, the purists will say that it is a closure. A closure (technically) does not have to be a lambda / anonymous sub / dynamically generated sub.