in reply to
Re: closure clarity, please
in thread closure clarity, please
sub definitions are parsed once only. The closure retains the value it had at that point in time.
Yes, subs are only parsed once, but that's irrelevant.
The capturing occurs when the code ref is created. That's when the sub is defined for named subs, and that's when the sub op is executed for anonymous subs.
Furthermore, closures capture variables, not values. The value of the variable can be changed, from both inside and outside the sub.