http://qs321.pair.com?node_id=246750


in reply to Re: Objects with Private Variables
in thread Objects with Private Variables

You missed the key point - the anonymous subroutine is a closure because it "captures" the $type, $class and $self instances. So when you call the function later the $self variable is still accessible from inside $closure thus it all works.