package Foo; sub foo : lvalue { my $self = shift; warn "Only first argument to method foo is used" if @_ > 1; $self->{ foo } = shift if @_; $self->{ foo }; } my $x = bless +{}, 'Foo'; $x->foo = 3; print $x->foo, "\n"; $x->foo++; print $x->foo, "\n"; $x->foo += 6; print $x->foo, "\n"; __END__ 3 4 10