I tested your code and am amazed to see it works. I don't understand!! I mean, I understand how to make a closure. But my intuition (which is apparently incorrect) says that sub get_count is redefined each time executing this block, thus capturing a new my $cnt each time. Can someone clear this up -- why doesn't this block redefine sub get_count each time?