Next Tricks of the Wizards 104

Typical AUTOLOAD Use: Accessor Methods

        package Object;
        my @attrs = qw(color size price ....);  # 637 of these
        my %is_attr = map {$_ => 1} @attrs;
        sub new {
          my $pack= shift;
          my %self;
          @self{@attrs} = @_;
          bless \%self => $pack;
        }
        ...


Next Copyright © 2003 M. J. Dominus