On 09/21/2006 07:08 PM, chen li wrote:
Hi all,I read some sections in perltoot. In section Autoloaded Data Methods I see some line codes as following: package Person; use Carp; our $AUTOLOAD; # it's a package global my %fields = ( name => undef, age => undef, peers => undef, ); sub new { my $class = shift; my $self = { _permitted => \%fields, %fields, }; bless $self, $class; return $self; } It looks like that _permitted => \%fields and %fields are redundant. [...]
That "redundancy" allows you to use inheritance. If you have a class Employee, with an expanded set of fields, this method makes it possible to add the fields without having to modify each method that uses them.
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
