more notes - hash key destruction happens at the right point but still won't work
[p5sagit/Mutually-Assured-Destruction.git] / notes / hash-key-destruction.pl
CommitLineData
f7926535 1#!/usr/bin/env perl
2
3use strict;
4use warnings;
5use Variable::Magic qw(wizard cast);
6
7BEGIN { package Foo; sub DESTROY { warn "in DESTROY\n"; } }
8
9my $wiz = wizard data => sub { $_[1] },
10 free => sub { warn "destroyed $_[1]!\n"; };
11
12my %objs;
13
14$objs{foo} = bless({}, 'Foo');
15
16cast $objs{foo}, $wiz, '$objs{foo}';
17
18delete $objs{foo};