my @parts; if ($msg->is_mime) { my @t_parts = $msg->parts(); while (shift @t_parts) { if ($_->mime_type eq 'text/plain') { push @parts, $_; next; } if ($_->mime_type eq 'multipart/mixed' || $_->mime_type eq 'multipart/alternative') { push @t_parts, $_->parts(); } } }