$test->foo("bob"); print "Bob:".$test->foo(); $test->foo(undef); print "Undef:".$test->foo(); #### sub foo { my ($this, $arg) = @_; $this->{foo} = $arg if @_>1; return $this->{foo}; }