]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blob - samples/copy.pl
This is 0.64
[perl/modules/Variable-Magic.git] / samples / copy.pl
1 #!/usr/bin/env perl
2
3 use strict;
4 use warnings;
5
6 use lib qw<blib/arch blib/lib>;
7 use Variable::Magic qw<wizard cast>;
8 use Tie::Hash;
9
10 my $wiz = wizard copy => sub { print STDERR "COPY $_[2] => $_[3]\n" },
11                  free => sub { print STDERR "FREE\n" };
12 my %h;
13 tie %h, 'Tie::StdHash';
14 %h = (a => 1, b => 2);
15 cast %h, $wiz;
16 $h{b} = 3;
17 my $x = delete $h{b};
18 $x == 3 or die 'incorrect';