# Only keep text parts my @keep = grep { $_->effective_type =~ m|^text/| } $entity->parts; $entity->parts(\@keep);