in reply to Extracting mail attachments

In order to extract attachments, you'd better look at one of the MIME modules. There's the full-blown MIME::Parser module, part of the MIME::Tools package... and looks like a few more candidates: MIME::Fast, MIME::Explode... the latter seems particularily aimed at your type of application:
MIME::Explode is perl module for parsing and decoding single or multipart MIME messages, and outputting its decoded components to a given directory ie, this module is designed to allows users to extract the attached files out of a MIME encoded email messages or mailboxes.