in reply to RegExp to delete mail attachments

Read Death to Dot Star!. Basically the star operator is greedy, and will eat AS MUCH as possible before matching the rest of the expression. So your first dot star will eat most of the 20MB file (i.e. all but the last occurance of the rest of the string), which probably causes some memory problems.

The solution is to either make the operator non-greedy (put a ? at the end: .*?) or to restate the regexp to get rid of the dot so it doesn't match as much.

In your case though, You'd probably be better off searching CPAN for some modules to parse the mail for you. Parsers are tricky beasts.