in reply to Any one-liners for set and get functions?

There are modules on CPAN that can generatore them for you on the fly. A big one (and, at first sight, a rather complex one) is Class::Accessor. Will that do?

There may be more lightweight ones available, but there's none that jumps at me right now.

Yet, the principle isn't hard. Take a look at the source of WWW::Webrobot::Attributes for example: it's just one import routine, that generates a (combined getter/setter) sub for each attribute.

Replies are listed 'Best First'.
Re^2: Any one-liners for set and get functions?
by grinder (Bishop) on Oct 05, 2007 at 08:59 UTC
    A big one (and, at first sight, a rather complex one) is Class::Accessor.

    See Adam Kennedy's persuasive arguments as to why Object::Tiny is a better choice.

    • another intruder with the mooring in the heart of the Perl

Re^2: Any one-liners for set and get functions?
by moritz (Cardinal) on Oct 05, 2007 at 09:14 UTC
    Another module that might be helpful is Moose, which provides a complete OO implementation