demonstrate self saving during DESTROY
[p5sagit/Mutually-Assured-Destruction.git] / notes / save-my-life.pl
diff --git a/notes/save-my-life.pl b/notes/save-my-life.pl
new file mode 100644 (file)
index 0000000..2e1e748
--- /dev/null
@@ -0,0 +1,18 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+my %objs;
+
+BEGIN {
+  package Foo;
+
+  sub DESTROY { warn "DESTROY\n"; $objs{$_[0]} = $_[0]; }
+}
+
+{
+  bless({}, 'Foo');
+}
+
+warn join(', ', %objs);