Parsing email is not a trivial task. Maybe using a CPAN library might be safer. I can't recommend anything (haven't used one yet), but someone else might have an idea what to use. I found http://search.cpan.org/~markov/MailTools-2.07 with a quick search, check out the demos
What you want is a parser. For simple line oriented tasks a FSM (Finite State Machine) is often a good practical solution that keeps the complexity in check. In Re^3: How to parse a text file there is a simple example of a FSM. What you do with $lineBufferStatus is already a simple FSM. But you would need at least another state that says "I'm at the To-line now"
By the way to check if an array is empty, int() is rather unusual. Well TMTOWTDI, but the following lines are equivalent and the last of them is commonly used and as safe as your version
if (int(@array)>0) { if (scalar(@array)>0) { if (@array>0) { if (@array) {
In reply to Re: Help appending data based on location
by jethro
in thread Help appending data based on location
by perlnewbie9292
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |