use strict; use warnings; package Blubb; sub new { my $this = bless {a=>42}; $this->{circular} = $this; } sub DESTROY { warn "DESTROY ". __PACKAGE__; } package SUPEREND; no warnings 'redefine'; my $orig_destroy= \&Blubb::DESTROY; my $persist = bless { count=>0}; *Blubb::DESTROY= sub { $orig_destroy->(@_); warn "Mini END"; $persist->{count}++; }; sub DESTROY { warn "DESTROY after $_[0]->{count} destroys ". __PACKAGE__; } package MAIN; my $b = Blubb->new; my $c = Blubb->new; my $d = Blubb->new; #### DESTROY Blubb at c:/tmp/pm/destruct_end.pl line 12 during global destruction. Mini END at c:/tmp/pm/destruct_end.pl line 25 during global destruction. DESTROY Blubb at c:/tmp/pm/destruct_end.pl line 12 during global destruction. Mini END at c:/tmp/pm/destruct_end.pl line 25 during global destruction. DESTROY Blubb at c:/tmp/pm/destruct_end.pl line 12 during global destruction. Mini END at c:/tmp/pm/destruct_end.pl line 25 during global destruction. DESTROY after 3 destroys SUPEREND at c:/tmp/pm/destruct_end.pl line 33 during global destruction.