From: Mike Guy Date: Tue, 3 Jan 2006 19:18:41 +0000 (+0000) Subject: Re: [perl #38034] A combination eval, DESTROY method and $@ - dangerous - bug X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f4551fcd8535f92b446c0bbb84dfd670a1f3eece;p=p5sagit%2Fp5-mst-13.2.git Re: [perl #38034] A combination eval, DESTROY method and $@ - dangerous - bug Message-Id: p4raw-id: //depot/perl@26625 --- diff --git a/pod/perlobj.pod b/pod/perlobj.pod index bcf56a7..6cfa20c 100644 --- a/pod/perlobj.pod +++ b/pod/perlobj.pod @@ -456,6 +456,11 @@ manipulating C<$_[0]> within the destructor. The object itself (i.e. the thingy the reference points to, namely C<${$_[0]}>, C<@{$_[0]}>, C<%{$_[0]}> etc.) is not similarly constrained. +Since DESTROY methods can be called at unpredictable times, it is +important that you localise any global variables that the method may +update. In particular, localise C<$@> if you use C and +localise C<$?> if you use C or backticks. + If you arrange to re-bless the reference before the destructor returns, perl will again call the DESTROY method for the re-blessed object after the current one returns. This can be used for clean delegation of