package 'Blah'; use Moose; has attributes => ( isa => 'HashRef' ); has attr1 => ( snip ); has attr2 => ( snip ); has content => (isa => 'HTML::Element'); sub BUILD { my $s = shift; # add attributes to object and/or HTML::ELEMENT in content attribute foreach my $attrib (keys %{$s->attribs}) { # set attributes of an object if it exists if ($s->can($attrib)) { $s->$attrib($s->attribs->{$attrib}); } # set attributes of #HTML::ELEMENT } else { $s->content->attr($attrib, $s->attribs->{$attrib}); } } }