So thats the accessor code you use. Cool. But wheres the DESTROY? And how do you manage it? Id expect some infrastructure to manage the attributes. Something like:
package Foo; use Scalar::Util qw(refaddr); use strict; use warnings; BEGIN { my @destroy; sub DESTROY { my $addr= refaddr $_[0]; foreach my $hash (@destroy) { delete $hash->{$addr}; } } sub reg_attr { push @destroy,\my %hash; \%hash } } BEGIN { my $attribute=reg_attr(); sub get_attribute{ $attribute->{refaddr $_[0]} } sub set_attribute{ $attribute->{refaddr $_[0]} = $_[1] } }
In reply to Re^2: Can I please have *simple* modules?
by demerphq
in thread Can I please have *simple* modules?
by Ovid
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |