in reply to Re: Tieing anonymous hashes
in thread Tieing anonymous hashes

In other words, this does work:

my $obj = tie( %hash, 'Class' ); $obj->DESTROY;

It works except that you'd never, ever write code to call ->DESTROY because that's only ever called by perl when it is actually destroying something. ->DESTROY doesn't provoke a cleanup - its only something that happens during cleanup.

Replies are listed 'Best First'.
Re^3: Tieing anonymous hashes
by davido (Cardinal) on Jun 28, 2005 at 22:39 UTC

    You are correct, sir.
    I was demonstrating that the return value of tie is an object reference that could be treated as such. My choice of DESTROY in the example was to use a method I knew should exist regardless of the class to which the variable is tied, that is common in any old ordinary class, and that people familiar with OO would visually recognize as a method call. But you're absolutely right about letting Perl call DESTROY().


    Dave

      So use ->can() or ->isa().