package Foo; sub new { my $class = shift; return bless {}, $class; } sub get_foo { my $self = shift; return $self->{foo}; } sub set_foo { my $self = shift; $self->{foo} = shift; } 1; #### sub foo { my $self = shift; if (@_) { # mutator $self->{foo} = shift; } else { # accessor return $self->{foo}; } }