You can use
either MIME::Lite or MIME::Parser to retrieve email attachments. In fact, a program doing just that has already been written and posted to PerlMonks some time ago.
Here's the node:
MIME Attachment Extractor
You may refer at the code for some concrete examples on how to implement the mentioned modules in your particular program in order for you to be able to extract your email attachments.
Cheers.
UPDATE: thanks
Joost, I shouldn't have mentioned
MIME::Lite. However,
MIME::Parse may still do a perfect job ;-)
_____________________
$"=q;grep;;$,=q"grep";for(`find . -name ".saves*~"`){s;$/;;;/(.*-(\d+)
+-.*)$/;$_=["ps -e -o pid | "," $2 | "," -v "," "]`@$_`?{print"
++ $1"}:{print"- $1"}&&`rm $1`;print"\n";}