# Open a handle to each part which is an attachment my @attachments= map +{ name => $_->head->recommended_filename, content_type => _decoded_mime_header($_->head, 'Content-Type'), handle => $_->bodyhandle->open('r'), mimepart => $_, email => $email }, grep length($_->head->recommended_filename//''), @leaf_parts; # Convert zipfile attachments to the list of files within @attachments= map { $_->{name} =~ /\.zip$/? _extract_zipfile($_) : ($_) } @attachments;