demonstrate self saving during DESTROY
[p5sagit/Mutually-Assured-Destruction.git] / notes / save-my-life-safely.pl
CommitLineData
68d6f889 1#!/usr/bin/env perl
2
3use strict;
4use warnings;
5use Devel::GlobalDestruction ();
6
7my %objs;
8
9BEGIN {
10 package Foo;
11
12 sub DESTROY {
13 warn "DESTROY\n";
14 return if Devel::GlobalDestruction::in_global_destruction();
15 $objs{$_[0]} = $_[0];
16 }
17}
18
19{
20 bless({}, 'Foo');
21}
22
23warn join(', ', %objs);