Try the CPAN repository at
CPAN to see if there isn't a module for this sort of thing. There is
MailTools. And
Mail::Box looks like a good start on all the functionality. The mail in /spool/mail/<user> is all in plain text so you should be able to simply read the file, if nothing else.