Thank you, that's it! Removing the exit call from DESTROY solves the problem.

-----Ursprüngliche Nachricht-----
Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Tom Phoenix
Gesendet: Mittwoch, 14. Juni 2006 18:15
An: Glaessl, Danilo
Cc: beginners@perl.org
Betreff: Re: DESTROY executed twice

On 6/13/06, Glaessl, Danilo <[EMAIL PROTECTED]> wrote:

>     sub DESTROY {

>         exit($exit_code);
>     }

I don't think that exit() will do what you might expect, when called from 
DESTROY. At that point, the DESTROY hasn't finished, so your object is still 
alive, and thus it will need to be sent DESTROY.... I don't know that this is 
why you're seeing it called twice, but my tests seem to bear that out:

  my $obj = bless {}, 'Tryout';
  my $count = 0;

  sub Tryout::DESTROY {
    print "This is destruction ", ++$count, "\n";
    exit($count);
  }

There may be other problems in your code as well, but this one jumps out at me. 
Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to