in reply to Re: Object scope and DESTROY
in thread Object scope and DESTROY

Thank you for the prompt reply. This certainly would work. What I am looking for though is an explanation of why, even though the object can't be accessed (I would assume it is out of scope), the DESTROY method is still not called.

UPDATE: I notice that the above post mentions the scope is that of the block surrounding the if. If that is true (I don't know if it is or not) why do I get a compile error when I add the following line at the end of my code (assuming that the $obj should still be in scope):
print "[".ref($obj)."]\n";


Any ideas?

my @a=qw(random brilliant braindead); print $a[rand(@a)];

Replies are listed 'Best First'.
Re: Re: Re: Object scope and DESTROY
by perrin (Chancellor) on Sep 24, 2001 at 22:07 UTC
    Well, that makes it look like it isn't the scope of the surrounding block either, so I'm not sure what scope it has. I suppose you could compare this with what happens when you just do a "my $obj = MyPack->new()" before the last "if".