Variable::Magic - Associate user-defined magic to variables from Perl.
VERSION
- Version 0.08
+ Version 0.10
SYNOPSIS
use Variable::Magic qw/wizard cast dispell/;
of the variable will trigger the callback. It is available on your
perl iff "MGf_LOCAL" is true.
- The following actions only applies to hashes and are available iff
+ The following actions only apply to hashes and are available iff
"VMG_UVAR" is true. They are referred to as "uvar" magics.
"fetch"
When this constant is true, you can use the "fetch,store,exists,delete"
callbacks on hashes.
+ "VMG_COMPAT_ARRAY_PUSH_NOLEN"
+ True for perls that don't call 'len' magic when you push an element in a
+ magical array.
+
+ "VMG_COMPAT_ARRAY_UNDEF_CLEAR"
+ True for perls that call 'clear' magic when undefining magical arrays.
+
+ "VMG_COMPAT_HASH_LISTASSIGN_COPY"
+ True for perls that call 'copy' magic on list assignments. Implies that
+ "MGf_COPY" is true.
+
FUNCTIONS
"wizard"
wizard sig => ...,
magic is already present, 0 on error, and "undef" when no magic
corresponds to the given signature (in case $sig was supplied). All
extra arguments specified after $wiz are passed to the private data
- constructor.
+ constructor. If the variable isn't a hash, any "uvar" callback of the
+ wizard is safely ignored.
# Casts $wiz onto $x. If $wiz isn't a signature, undef can't be returned.
my $x;
"MGf_LOCAL" and "VMG_UVAR" are also only exported on request. They are
all exported by the tags ':consts' and ':all'.
+CAVEATS
+ If you store a magic object in the private data slot, the magic won't be
+ accessible by "getdata" since it's not copied by assignation. The only
+ way to address this would be to return a reference.
+
+ If you define a wizard with a "free" callback and cast it on itself,
+ this destructor won't be called because the wizard will be destroyed
+ first.
+
DEPENDENCIES
perl 5.7.3.