]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blobdiff - lib/Variable/Magic.pm
Reference count vmg_op_name_len
[perl/modules/Variable-Magic.git] / lib / Variable / Magic.pm
index 27e482c33c19639b6204c9b87317aa0b9fc740f3..4456efbaa6f11187b9903e7f6102cfac4cef569e 100644 (file)
@@ -13,13 +13,13 @@ Variable::Magic - Associate user-defined magic to variables from Perl.
 
 =head1 VERSION
 
-Version 0.29
+Version 0.30
 
 =cut
 
 our $VERSION;
 BEGIN {
- $VERSION = '0.29';
+ $VERSION = '0.30';
 }
 
 =head1 SYNOPSIS
@@ -53,7 +53,7 @@ It doesn't replace the original semantics : magic callbacks trigger before the o
 
 =item *
 
-It's mostly invisible at the Perl level : magical and non-magical variables cannot be distinguished with C<ref>, C<reftype> or another trick.
+It's mostly invisible at the Perl level : magical and non-magical variables cannot be distinguished with C<ref>, C<tied> or another trick.
 
 =item *
 
@@ -423,6 +423,15 @@ If the variable isn't a hash, any C<uvar> callback of the wizard is safely ignor
     my $x;
     die 'error' unless cast $x, $wiz;
 
+The C<var> argument can be an array or hash value.
+Magic for those behaves like for any other scalar, except that it is dispelled when the entry is deleted from the container.
+For example, if you want to call C<POSIX::tzset> each time the C<'TZ'> environment variable is changed in C<%ENV>, you can use :
+
+    use POSIX;
+    cast $ENV{TZ}, wizard set => sub { POSIX::tzset(); () };
+
+If you want to overcome the possible deletion of the C<'TZ'> entry, you have no choice but to rely on C<store> uvar magic.
+
 =head2 C<getdata>
 
     getdata [$@%&*]var, [$wiz|$sig]
@@ -470,8 +479,6 @@ our %EXPORT_TAGS    = (
 our @EXPORT_OK      = map { @$_ } values %EXPORT_TAGS;
 $EXPORT_TAGS{'all'} = [ @EXPORT_OK ];
 
-END { _cleanup() }
-
 =head1 CAVEATS
 
 If you store a magic object in the private data slot, the magic won't be accessible by L</getdata> since it's not copied by assignation.