in reply to simple mail filter

It's not Perl, but you might consider using formail for this. A snippet from the formail manpage:
NAME formail - mail (re)formatter [...] DESCRIPTION formail is a filter that can be used to force mail into mailbox format, perform `From ' escaping, generate auto- replying headers, do simple header munging/extracting or split up a mailbox/digest/articles file.