Uh... well, it's a special block... so it's... uh... handled "specially". <insert lots of handwaving>

Frankly, I'd be more than happy to listen to a real explanation from someone who knows. :-)

By the way, as of 5.6, dies within a DESTROY are visible if you run with warnings enabled. Here's the relevant passage from perldoc perl56delta:

Failures in DESTROY() When code in a destructor threw an exception, it went unnoticed + in ear- lier versions of Perl, unless someone happened to be looking in + $@ just after the point the destructor happened to run. Such failures +are now visible as warnings when warnings are enabled.
And another example:
$ perl -wle 'sub DESTROY { die "dead" }; { bless \my $o }' (in cleanup) dead at -e line 1.

Update: Also worth noting, the entry from perldoc perldiag:

(in cleanup) %s (W misc) This prefix usually indicates that a DESTROY() met +hod raised the indicated exception. Since destructors are usua +lly called by the system at arbitrary points during execution, +and often a vast number of times, the warning is issued only on +ce for any number of failures that would otherwise result in the s +ame message being repeated.
That implies that if DESTROY prints the same thing each time, the warning will only be printed once. If the warning is different each time, however, it should be printed each time. More examples to substantiate that:
$ perl -wle 'sub DESTROY { die "dead" }; { bless \my $o; bless \my $p +}' (in cleanup) dead at -e line 1. $ perl -wle 'sub DESTROY { die "dead: $_[0]"}; { bless \my $o; bless \ +my $p }' (in cleanup) dead: main=SCALAR(0x805f0d4) at -e line 1. (in cleanup) dead: main=SCALAR(0x805f164) at -e line 1.

Edit: Replaced

$ perl -wle 'my $c=0; sub DESTROY { die "dead: ",$c++; }; { bless \my +$o; bless \my $p }' (in cleanup) dead: 0 at -e line 1. (in cleanup) dead: 1 at -e line 1.
with a better example.

-sauoq
"My two cents aren't worth a dime.";

In reply to Re: Re: Re: die & DESTROY - but not at the same time? by sauoq
in thread die & DESTROY - but not at the same time? by mildside

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.