]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blobdiff - samples/copy.pl
Importing Variable-Magic-0.16.tar.gz
[perl/modules/Variable-Magic.git] / samples / copy.pl
diff --git a/samples/copy.pl b/samples/copy.pl
new file mode 100755 (executable)
index 0000000..f716906
--- /dev/null
@@ -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';