in reply to Spliting an mbox file

Simple answer: don't reinvent the wheel, use someone else's wheel that works.

Update: And as to your error message, your array initially doesn't have anything in it so $#array is -1. -1 elements from the end of an empty array isn't a valid index. See perldiag. Which means that your file doesn't start with a 'From ' line, or at least not one which matches the regexp you're trying to use.