X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=samples%2Fcopy.pl;fp=samples%2Fcopy.pl;h=f7169069b0ea1ff2706e3a31959143d00cc9829e;hb=c471e8c9f86ad8817761816101358f8ae1035915;hp=0000000000000000000000000000000000000000;hpb=91aec4cfae75e61ff8eeb79448501a8739b0d240;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/samples/copy.pl b/samples/copy.pl new file mode 100755 index 0000000..f716906 --- /dev/null +++ b/samples/copy.pl @@ -0,0 +1,18 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +use lib qw{blib/arch blib/lib}; +use Variable::Magic qw/wizard getsig cast/; +use Tie::Hash; + +my $wiz = wizard copy => sub { print STDERR "COPY $_[2] => $_[3]\n" }, + free => sub { print STDERR "FREE\n" }; +my %h; +tie %h, 'Tie::StdHash'; +%h = (a => 1, b => 2); +cast %h, $wiz; +$h{b} = 3; +my $x = delete $h{b}; +$x == 3 or die 'incorrect';