=head1 VERSION
-Version 0.38
+Version 0.40
=cut
our $VERSION;
BEGIN {
- $VERSION = '0.38';
+ $VERSION = '0.40';
}
=head1 SYNOPSIS
=head2 Associate an object to any perl variable
-This can be useful for passing user data through limited APIs.
+This technique can be useful for passing user data through limited APIs.
+It is similar to using inside-out objects, but without the drawback of having to implement a complex destructor.
{
package Magical::UserData;
my ($var) = @_;
my $data = &getdata($var, $wiz);
unless (defined $data) {
- &cast($var, $wiz);
- $data = &getdata($var, $wiz);
- die "Couldn't cast UserData magic onto the variable" unless defined $data;
+ $data = \(my $slot);
+ &cast($var, $wiz, $slot)
+ or die "Couldn't cast UserData magic onto the variable";
}
$$data;
}
=head1 COPYRIGHT & LICENSE
-Copyright 2007-2009 Vincent Pit, all rights reserved.
+Copyright 2007,2008,2009,2010 Vincent Pit, all rights reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.