$email = Email::MIME->new (\$msg); $email->walk_parts( sub { return if $_[0]->subparts; print $_[0]->filename; } );