The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
use v6-alpha;

=pod

=head1 Destroying an object

=head2 Problem

You want to run special code when an object is no longer used.

=head2 Solution

Provide a C<DESTROY> method.

=cut

class Foo {
    method DESTROY {
        say "An instance of Foo is going out of scope";
    }
}

my $foo = Foo.new;