Variable::Magic 0.48

Perl Artistic License

Variable::Magic 0.48

Magic is Perl way of enhancing objects. This mechanism lets the user add extra data to any variable and hook syntaxical operations (such as access, assignment or destruction) that can be applied to it. With this module, you can add your own magic to any variable without having to write a single line of XS.

You'll realize that these magic variables look a lot like tied variables. It's not surprising, as tied variables are implemented as a special kind of magic, just like any 'irregular' Perl variable : scalars like $!, $( or $^W, the %ENV and %SIG hashes, the @ISA array, vec() and substr() lvalues, threads::shared variables... They all share the same underlying C API, and this module gives you direct access to it.


 use Variable::Magic qw/wizard cast VMG_OP_INFO_NAME/;

 { # A variable tracer
 my $wiz = wizard set => sub { print "now set to ${$_[0]}!\n" },
 free => sub { print "destroyed!\n" };

 my $a = 1;
 cast $a, $wiz;
 $a = 2; # "now set to 2!"
 } # "destroyed!"

 { # A hash with a default value
 my $wiz = wizard data => sub { $_[1] },
 fetch => sub { $_[2] = $_[1] unless exists $_[0]->{$_[2]}; () },
 store => sub { print "key $_[2] stored in $_[-1]\n" },
 copy_key => 1,
 op_info => VMG_OP_INFO_NAME;

 my %h = (_default => 0, apple => 2);
 cast %h, $wiz, '_default';
 print $h{banana}, "\n"; # "0", because the 'banana' key doesn't exist in %h
 $h{pear} = 1; # "key pear stored in helem"

Product's homepage


· Perl

Download and use it now: Variable::Magic 0.48 free download

Add a review

Tell us your experience with Variable::Magic 0.48

Related programsOur Recommendations

LibreOffice 3.5.5 / 3.6.0 RC1

LibreOffice is a productivity suite that is compatible with other major office suites, and


Majic 0.01pre2

Majic is the interpreter for a language called Erc. It is written in Java and follows the


Transcribe! 8.10

Transcribe! project is an assistant for people who sometimes want to work out a piece of music from


Thousand Parsec C++ Server 0.6.2

Thousand Parsec C++ Server is the main server for Thousand Parsec.Thousand Parsec is a framework


django-eggproxy 0.0.1

django-eggproxy is a Django app that provides a PyPi eggproxy.Product's


Casus: Follow the Beam 13.4062.3450

Help the alien survive on this strange planet. Don't touch the beam. Turn the screen when needed,


Equinox Blue Abomination

Equinox Blue Abomination package provides a GTK theme for GNOME using the powerful Equinox GTK2


Scrollbar Search Highlighter 1.57

Scrollbar Search Highlighter is a Firefox add-on that works with the Finder (Ctrl+F) to help the


djlime-news 1.0.0

djlime-news is a Django news application.Product's homepageRequirements: · Python ·


KonsoleLock 0.1

KonsoleLock simple asks for three pin numbers, verifies them as you enter them, and if correct,


Thumbnail of Variable::Magic 0.48


4 stars

Price: FREE

Publisher/Developer: Vincent Pit

Release Date: Jun 23, 2012

View Program Details

Top Downloadslast week