=item *
-C<get>
+I<get>
This magic is invoked when the variable is evaluated.
It is never called for arrays and hashes.
=item *
-C<set>
+I<set>
This magic is called each time the value of the variable changes.
It is called for array subscripts and slices, but never for hashes.
=item *
-C<len>
+I<len>
This magic only applies to scalars and arrays, and is triggered when the 'size' or the 'length' of the variable has to be known by Perl.
This is typically the magic involved when an array is evaluated in scalar context, but also on array assignment and loops (C<for>, C<map> or C<grep>).
=item *
-C<clear>
+I<clear>
This magic is invoked when the variable is reset, such as when an array is emptied.
Please note that this is different from undefining the variable, even though the magic is called when the clearing is a result of the undefine (e.g. for an array, but actually a bug prevent it to work before perl 5.9.5 - see the L<history|/PERL MAGIC HISTORY>).
=item *
-C<free>
+I<free>
This magic is called when an object is destroyed as the result of the variable going out of scope (but not when the variable is undefined).
=item *
-C<copy>
+I<copy>
This magic only applies to tied arrays and hashes, and fires when you try to access or change their elements.
=item *
-C<dup>
+I<dup>
This magic is invoked when the variable is cloned across threads.
It is currently not available.
=item *
-C<local>
+I<local>
When this magic is set on a variable, all subsequent localizations of the variable will trigger the callback.
It is available on your perl if and only if C<MGf_LOCAL> is true.
=back
The following actions only apply to hashes and are available if and only if L</VMG_UVAR> is true.
-They are referred to as C<uvar> magics.
+They are referred to as I<uvar> magics.
=over 4
=item *
-C<fetch>
+I<fetch>
This magic is invoked each time an element is fetched from the hash.
=item *
-C<store>
+I<store>
This one is called when an element is stored into the hash.
=item *
-C<exists>
+I<exists>
This magic fires when a key is tested for existence in the hash.
=item *
-C<delete>
+I<delete>
This magic is triggered when a key is deleted in the hash, regardless of whether the key actually exists in it.
=item *
-C<len>
+I<len>
-C<$_[2]> contains the natural, non-magical length of the variable (which can only be a scalar or an array as len magic is only relevant for these types).
+C<$_[2]> contains the natural, non-magical length of the variable (which can only be a scalar or an array as I<len> magic is only relevant for these types).
The callback is expected to return the new scalar or array length to use, or C<undef> to default to the normal length.
=item *
-C<copy>
+I<copy>
C<$_[2]> is a either an alias or a copy of the current key, and C<$_[3]> is an alias to the current element (i.e. the value).
Because C<$_[2]> might be a copy, it is useless to try to change it or cast magic on it.
=item *
-C<fetch>, C<store>, C<exists> and C<delete>
+I<fetch>, I<store>, I<exists> and I<delete>
C<$_[2]> is an alias to the current key.
Note that C<$_[2]> may rightfully be readonly if the key comes from a bareword, and as such it is unsafe to assign to it.
Both result in a small performance hit, but just getting the name is lighter than getting the op object.
These callbacks are executed in scalar context and are expected to return an integer, which is then passed straight to the perl magic API.
-However, only the return value of the C<len> callback currently holds a meaning.
+However, only the return value of the I<len> magic callback currently holds a meaning.
=back
=item *
a reference to C<undef>, in which case a no-op magic callback is installed instead of the default one.
-This may especially be helpful for 'local' magic, where an empty callback prevents magic from being copied during localization.
+This may especially be helpful for I<local> magic, where an empty callback prevents magic from being copied during localization.
=back
-Note that C<free> callbacks are I<never> called during global destruction, as there is no way to ensure that the wizard object and the C<free> callback were not destroyed before the variable.
+Note that I<free> magic is never called during global destruction, as there is no way to ensure that the wizard object and the callback were not destroyed before the variable.
Here is a simple usage example :
use POSIX;
cast $ENV{TZ}, wizard set => sub { POSIX::tzset(); () };
-If you want to handle the possible deletion of the C<'TZ'> entry, you must also specify C<store> uvar magic.
+If you want to handle the possible deletion of the C<'TZ'> entry, you must also specify I<store> magic.
=head2 C<getdata>
=head2 C<MGf_COPY>
-Evaluates to true if and only if the 'copy' magic is available.
+Evaluates to true if and only if the I<copy> magic is available.
This is the case for perl 5.7.3 and greater, which is ensured by the requirements of this module.
=head2 C<MGf_DUP>
-Evaluates to true if and only if the 'dup' magic is available.
+Evaluates to true if and only if the I<dup> magic is available.
This is the case for perl 5.7.3 and greater, which is ensured by the requirements of this module.
=head2 C<MGf_LOCAL>
-Evaluates to true if and only if the 'local' magic is available.
+Evaluates to true if and only if the I<local> magic is available.
This is the case for perl 5.9.3 and greater.
=head2 C<VMG_UVAR>
-When this constant is true, you can use the C<fetch,store,exists,delete> callbacks on hashes.
+When this constant is true, you can use the I<fetch>, I<store>, I<exists> and I<delete> magics on hashes.
Initial L</VMG_UVAR> capability was introduced in perl 5.9.5, with a fully functional implementation shipped with perl 5.10.0.
=head2 C<VMG_COMPAT_SCALAR_LENGTH_NOLEN>
-True for perls that don't call 'len' magic when taking the C<length> of a magical scalar.
+True for perls that don't call I<len> magic when taking the C<length> of a magical scalar.
=head2 C<VMG_COMPAT_ARRAY_PUSH_NOLEN>
-True for perls that don't call 'len' magic when you push an element in a magical array.
+True for perls that don't call I<len> magic when you push an element in a magical array.
Starting from perl 5.11.0, this only refers to pushes in non-void context and hence is false.
=head2 C<VMG_COMPAT_ARRAY_PUSH_NOLEN_VOID>
-True for perls that don't call 'len' magic when you push in void context an element in a magical array.
+True for perls that don't call I<len> magic when you push in void context an element in a magical array.
=head2 C<VMG_COMPAT_ARRAY_UNSHIFT_NOLEN_VOID>
-True for perls that don't call 'len' magic when you unshift in void context an element in a magical array.
+True for perls that don't call I<len> magic when you unshift in void context an element in a magical array.
=head2 C<VMG_COMPAT_ARRAY_UNDEF_CLEAR>
-True for perls that call 'clear' magic when undefining magical arrays.
+True for perls that call I<clear> magic when undefining magical arrays.
=head2 C<VMG_COMPAT_HASH_DELETE_NOUVAR_VOID>
-True for perls that don't call 'delete' uvar magic when you delete an element from a hash in void context.
+True for perls that don't call I<delete> magic when you delete an element from a hash in void context.
=head2 C<VMG_COMPAT_GLOB_GET>
-True for perls that call 'get' magic for operations on globs.
+True for perls that call I<get> magic for operations on globs.
=head2 C<VMG_PERL_PATCHLEVEL>
B<5.6.x>
-I<p14416> : 'copy' and 'dup' magic.
+I<p14416> : I<copy> and I<dup> magic.
=item *
B<5.9.3>
-I<p25854> : 'len' magic is no longer called when pushing an element into a magic array.
+I<p25854> : I<len> magic is no longer called when pushing an element into a magic array.
-I<p26569> : 'local' magic.
+I<p26569> : I<local> magic.
=item *
B<5.9.5>
-I<p31064> : Meaningful 'uvar' magic.
+I<p31064> : Meaningful I<uvar> magic.
-I<p31473> : 'clear' magic was not invoked when undefining an array.
+I<p31473> : I<clear> magic was not invoked when undefining an array.
The bug is fixed as of this version.
=item *
B<5.10.0>
-Since C<PERL_MAGIC_uvar> is uppercased, C<hv_magic_check()> triggers 'copy' magic on hash stores for (non-tied) hashes that also have 'uvar' magic.
+Since C<PERL_MAGIC_uvar> is uppercased, C<hv_magic_check()> triggers I<copy> magic on hash stores for (non-tied) hashes that also have I<uvar> magic.
=item *
B<5.11.x>
-I<p32969> : 'len' magic is no longer invoked when calling C<length> with a magical scalar.
+I<p32969> : I<len> magic is no longer invoked when calling C<length> with a magical scalar.
-I<p34908> : 'len' magic is no longer called when pushing / unshifting an element into a magical array in void context.
+I<p34908> : I<len> magic is no longer called when pushing / unshifting an element into a magical array in void context.
The C<push> part was already covered by I<p25854>.
-I<g9cdcb38b> : 'len' magic is called again when pushing into a magical array in non-void context.
+I<g9cdcb38b> : I<len> magic is called again when pushing into a magical array in non-void context.
=back
If you want to store a magic object in the private data slot, you will not be able to recover the magic with L</getdata>, since magic is not copied by assignment.
You can work around this gotcha by storing a reference to the magic object instead.
-If you define a wizard with a C<free> callback and cast it on itself, it results in a memory cycle, so this destructor will not be called when the wizard is freed.
+If you define a wizard with I<free> magic and cast it on itself, it results in a memory cycle, so this destructor will not be called when the wizard is freed.
=head1 DEPENDENCIES