| Server IP : 217.160.0.212 / Your IP : 216.73.216.242 Web Server : Apache System : Linux info 3.0 #1337 SMP Tue Jan 01 00:00:00 CEST 2000 all GNU/Linux User : u119869361 ( 9600978) PHP Version : 8.4.28 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /kunden/proc/self/root/proc/thread-self/root/usr/share/doc/libvariable-magic-perl/examples/ |
Upload File : |
#!/usr/bin/perl
use strict;
use warnings;
use lib qw<blib/arch blib/lib>;
use Variable::Magic qw<wizard cast dispell>;
sub foo { print STDERR "got ${$_[0]}!\n" }
my $bar = sub { ++${$_[0]}; print STDERR "now set to ${$_[0]}!\n"; };
my $a = 1;
{
my $wiz = wizard get => \&foo,
set => $bar,
free => sub { print STDERR "deleted!\n"; };
cast $a, $wiz, qw<a b c>;
++$a; # "got 1!", "now set to 3!"
dispell $a, $wiz;
cast $a, $wiz;
my $b = 123;
cast $b, $wiz;
} # "deleted!"
my $b = $a; # "got 3!"
$a = 3; # "now set to 4!"
$b = 3; # (nothing)