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
1 #!/usr/bin/env perl
2
3 use strict;
4 use warnings;
5 use Variable::Magic qw(wizard cast);
6
7 BEGIN { package Foo; sub DESTROY { warn "in DESTROY\n"; } }
8
9 my $wiz = wizard data => sub { $_[1] },
10                  free => sub { warn "destroyed $_[1]!\n"; };
11
12 my %objs;
13
14 $objs{foo} = bless({}, 'Foo');
15
16 cast $objs{foo}, $wiz, '$objs{foo}';
17
18 delete $objs{foo};