in reply to if(my) scope
the phenomenon you noted is absolutly normal, if the reference count of $h goes to zero, it is automatically freed by perl, since it is associated with a object, the DESTROY method in the class will be called.
see perltoot Destructors
I generally talked about the way the DESTROY is called, but this is new to me, pardon if it caused some confusion.
-- In accordance with the prarabdha of each, the One whose function it is to ordain makes each to act. What will not happen will never happen, whatever effort one may put forth. And what will happen will not fail to happen, however much one may seek to prevent it. This is certain. The part of wisdom therefore is to stay quiet.