for my $att (qw/x y w h/) { my $predicate = "has_$att"; $attr{$att} = $self->$att if $self->$predicate; }