NAMES Class::Accessor - automated accessor generation Class::Accessor::Fast - faster automated accessor generation Class::Accessor::Faster - even faster, using an array DESCRIPTION This module automagically generates accessors/mutators for your class. Most of the time, writing accessors is an exercise in cutting and pasting. You usually wind up with a series of methods like this: sub name { my $self = shift; if(@_) { $self->{name} = $_[0]; } return $self->{name}; } sub salary { my $self = shift; if(@_) { $self->{salary} = $_[0]; } return $self->{salary}; } # etc... One for each piece of data in your object. While some will be unique, doing value checks and special storage tricks, most will simply be exercises in repetition. Not only is it Bad Style to have a bunch of repetitious code, but it's also simply not lazy, which is the real tragedy. If you make your module a subclass of Class::Accessor and declare your accessor fields with mk_accessors() then you'll find yourself with a set of automatically generated accessors which can even be customized! The basic set up is very simple: package My::Class; use base qw(Class::Accessor); My::Class->mk_accessors( qw(foo bar car) ); Done. My::Class now has simple foo(), bar() and car() accessors defined. BENCHMARKS accessors: Rate Basic Average Fast Faster Direct Basic 189150/s -- -42% -51% -55% -89% Average 327679/s 73% -- -16% -22% -82% Fast 389212/s 106% 19% -- -8% -78% Faster 421646/s 123% 29% 8% -- -76% Direct 1771243/s 836% 441% 355% 320% -- mutators: Rate Basic Average Fast Faster Direct Basic 173769/s -- -34% -53% -59% -90% Average 263046/s 51% -- -29% -38% -85% Fast 371158/s 114% 41% -- -13% -78% Faster 425821/s 145% 62% 15% -- -75% Direct 1699081/s 878% 546% 358% 299% -- AUTHORS Copyright 2007 Marty Pauley This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. That means either (a) the GNU General Public License or (b) the Artistic License. ORIGINAL AUTHOR Michael G Schwern