in reply to Evaluation of Simple Pop3 Client
But in fact I would drop the $count altogether. Rather than do an infinite loop in which you increment and test $count (sort of like a hand-rolled C-style for loop) just loop over the array:$MsgCount->[$count];
which is going to be faster and gives more hints to the person reading the code about what your intent is. This may mean moving actions you now have on the final iteration of the loop outside of it. That is another stylistic change I would approve of. Things in the loop are things you expect to do on each iteration. Things outside are not.foreach my $MsgLine (@$MsgContent) { ... }
Remember that debugging is largely an exercise in guessing where the code does not do what the programmer intended. Therefore subtle (and not so subtle) clues about your intent will help in debugging and maintainance.
If you expect to have only 2 elements in a split, then use the third argument to split.
I would rethink the scope of some of your variables. If they are private, they should be declared in a tight scope. If they are global, I would prefer to see them declared with vars. If they are per message (which they appear to be) then perhaps a hash would make more sense.
And one bug alert. Microsoft a long time ago put into all of their tools the ability to recognize the end of a header by the fact that you have seen all required fields, making the return superfluous for them. About a year ago IIRC they then dropped the return separating header from body from Outlook 2000. The result was an upgrade which worked fine for anyone running Outlook, but would cause all sorts of fun for people using other email programs.
The hope, of course, was that people would blame their own email programs for crashing since others got their email and it worked just fine. I won't say it didn't work. But I will say that this is the kind of dirty pool that makes me despise Microsoft. No, I don't appreciate their making other people's lives harder for reasons that I don't agree with. But the fact is that they do, and you need to be aware of it.
So I recommend finding someone with Outlook 2000 (I believe that that is the one that mangled the standard) and getting them to send you sample messages so you can analyze their dirty pool and waste time and energy you shouldn't have had to working around their crap...
|
---|