in reply to Re: Re: Re: accessor abuse..?
in thread accessor abuse..?

I agree with you about using an empty string, but if you are going to be ignoring the undef case, then it probably should be documented because if someone, like me, were to wonder upon that bit of code, s/he might be tempted to see the behaviour as a bug and not a feature (after all it did not do what I told it to when I spoke $self->foo(undef) :) So maybe:

########## # foo() # Sets or returns the value of foo. # But will keep the old value of foo # if undef be passed in sub foo{ # Do foo stuff }

Another option would be to use a different function name that reflects the no-blow-away-existing-values-on-undef behaviour.