in reply to Saving attachments from email files

You're part-way there with MIME::Parser, but you're not actually using the return value of ->parse() for some reason. Try something like this as a starting point:

my $entity = $parser->parse( IO::File->new( "$dir/raw-message.$i") ); foreach my $part ($entity->parts()) { # Look at $part (a MIME::Entity object) and determine what to do +with it }

MIME::Parser::parse() will return a top-level MIME::Entity object for the message. If it's a multipart message, you can get the separate MIME::Entity objects for each subpart by iterating over $entity->parts().

Then in that foreach loop, you can examine the content-type or filename of each part and determine what you want to do with it.