in reply to Is it legal to create subs in a module?
Methods are stored at the class level, not at the object level. In Perl terms, when you create a method you are installing a subroutine in the symbol table for your package. Removing an object doesn't do anything to the package's symbol table.
A better way to do this is using AUTOLOAD like this:
sub AUTOLOAD { my ($pkg, $attr) = $AUTOLOAD =~ /(.*)::(.*)/; *{$attr} = sub { return $_[0]->{$attr} }; return $_[0]->{$attr}; }
Although that still doesn't solve your main problem.
--"The first rule of Perl club is you don't talk about Perl club."
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Is it legal to create subs in a module?
by runrig (Abbot) on Oct 11, 2001 at 20:00 UTC | |
by davorg (Chancellor) on Oct 11, 2001 at 20:17 UTC | |
|
Re: Re: Is it legal to create subs in a module?
by Fletch (Bishop) on Oct 11, 2001 at 20:27 UTC |