foreach $x (@attypes){ if ($subentity->mime_type =~ m/$x/i){ $attachment = $subentity->bodyhandle->print(); push @attachment, $attachment; print "x = $x subentity =".$subentity->mime_type."\n"; push @attname, $subentity->head->mime_attr('content-disposition.filename'); } }