Commit | Line | Data |
---|---|---|
f7926535 | 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}; |