See dialup spam removal with Net::POP3 and look at the improvements by aristotle. You can setup big pre-compiled regexes based on lists of criteria. It uses qr/ / (quoted regex) to make a hash of regexes to test against, then the file is handled accordingly.