From: Matt S Trout Date: Mon, 15 Jun 2009 19:22:17 +0000 (+0100) Subject: more notes - hash key destruction happens at the right point but still won't work X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f7926535e963d2b6c3272cdf60e757d5151d5321;p=p5sagit%2FMutually-Assured-Destruction.git more notes - hash key destruction happens at the right point but still won't work --- diff --git a/notes/hash-key-destruction.pl b/notes/hash-key-destruction.pl new file mode 100644 index 0000000..30ca719 --- /dev/null +++ b/notes/hash-key-destruction.pl @@ -0,0 +1,18 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use Variable::Magic qw(wizard cast); + +BEGIN { package Foo; sub DESTROY { warn "in DESTROY\n"; } } + +my $wiz = wizard data => sub { $_[1] }, + free => sub { warn "destroyed $_[1]!\n"; }; + +my %objs; + +$objs{foo} = bless({}, 'Foo'); + +cast $objs{foo}, $wiz, '$objs{foo}'; + +delete $objs{foo};