http://www.perlmonks.org?node_id=264924


in reply to OO style question: how much information to hide?

The explicit delete ... if ... seems more readable to me, in a narrative sense. Somebody else taking a casual glance at the other chunk might be concerned that time was being spent deleting attributes from end tags. It wouldn't take them long to discover the truth of the matter, but it's still something in the back of their head.

On the other hand, perhaps you want a method besides as_is() for printing purposes? Maybe something like this:

sub cleaned_up { my $self = shift; $self->del_attr('font') if $self->is_start_tag; return $self->as_is; } ... print $token->cleaned_up;

Of course, this example could be modified for the realities of style and ... well ... reality :-)