in reply to Re: accessor abuse..?
in thread accessor abuse..?
Don't you to return $this->{foo} and not $this->foo.
Also, foo() breaks if you try to undefine $this->{foo} as in $this->foo(undef); so:
Will give:$test->foo("bob"); print "Bob:".$test->foo(); $test->foo(undef); print "Undef:".$test->foo();
Bob:bob Undef:Instead of checking for defined() maybe look @ the number of args that are passed into foo, like such:
sub foo { my ($this, $arg) = @_; $this->{foo} = $arg if @_>1; return $this->{foo}; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: accessor abuse..?
by djantzen (Priest) on Aug 22, 2002 at 15:45 UTC | |
by tantarbobus (Hermit) on Aug 22, 2002 at 17:17 UTC |