note
Anonymous Monk
I prefer "fixing" this at the source. I tend to have methods that are purely called for their side-effects, and not for their return values, return the object they acted upon.
<p>
And that includes accessors. Tk does it that way as well, and I like it. Example:
<code>
sub accessor {
my $self = shift;
if (@_) { # Sets the attribute.
$$self{key} = shift;
return $self;
}
return $$self{key}; # Gets the attribute.
}
</code>
Then you can write code like this:
<code>
my $obj->key1(value1)
->key2(value2)
->key3(value3);
</code>
417405
417405
3