The accessors pragma lets you create simple accessors at compile-time.

This saves you from writing them by hand, which tends to result in
cut-n-paste errors and a mess of duplicated code. It can also help you
reduce the ammount of unwanted direct-variable access that may creep
into your codebase when you're feeling lazy. accessors was designed
with laziness in mind.

Method-chaining accessors are generated by default. Note that you can still use
accessors::chained directly for reasons of backwards compatability.

See accessors::classic for accessors that always return the current value if you
don't like method chaining.

to make it difficult to accidentally access the property directly ala:

use accessors qw( foo );
$obj->{foo}; # prevents this by mistake
$obj->foo; # when you probably meant this

(this might sound woolly, but it's easy enough to do).

•

syntactic sugar (this is woolly :).

You shouldn't care too much about how the property is stored anyway - if you do,
you're likely trying to do something special (and should really consider
writing the accessors out long hand), or it's simply a matter of preference in
which case you can use accessors::classic, or sub-class this module.

If you prefer a different style of accessor or you need to do something more
complicated, there's nothing to stop you from sub-classing. It should be
pretty easy. Look through accessors::classic, accessors::ro, and accessors::rw
to see how it's done.

Thanks to Michael G. Schwern for indirectly inspiring this module, and for his
feedback & suggestions.

Also to Paul Makepeace and David Wright for showing me faster accessors, to
chocolateboy for his contributions, the CPAN Testers for their bug reports,
and to James Duncan and people on London.pm for their feedback.