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.";
|