in reply to PineTOC

First off, not a bad bit of code. I notice that you're checking the returns from your opens, which is a very good thing.

I can't help but wonder why, in WriteTOCline, you take the two-step approach of sprintf followed by print instead of just using printf.

And now, a few more Perlish ways to do a few things:

You can shorten if ($_ =~ /^X-UIDL: \w{32}/) { to if (/^X-UIDL: \w{32}/) {. The $_ is implied on matches unless another variable is explicitly used.

All instances of $Variable = $Variable + n can be shortened to $Variable += n with no loss of readability to anyone who knows Perl (or C, for that matter).

Probably the biggest change you could make, and one which would be very educational for you, would be to read RFC 822, which defines the format of email messages, and use that knowledge to set $/ to something useful so that you could slurp up whole messages at a time instead of reading them one line at a time.

Finally, I'll rain on your parade a bit by telling you that you're reinventing the wheel. If you want the semi-official Perl package for handling email, have a look at Graham Barr's MailTools bundle.

*Woof*

Replies are listed 'Best First'.
RE: RE: PineTOC
by Tally (Novice) on Aug 01, 2000 at 18:54 UTC
    Thanks for your input. I updated my code based on your comments.

    I originally used the "sprintf" followed by "print" because I didn't know the "printf" command would take formatting. Thanks for pointing this out!

    I've read parts of RFC822 in the past, but I'm not sure how relavant it would be to this situation. PINE stores its messages with all the RFC headers, true.. but is the PINE message store totally 822 compliant? Maybe it is, but I assume that PINE probably changes the formatting of the messages and headers slightly when it stores them. Certainly, the messages in the store don't end in a single period on a line by itself (the signal for the end of an SMTP email). Still, I'm sure you're right in saying that there is a more efficient way to "slurp up whole messages".

    Thanks for the reference to MailTools. I'll take a look.

    Tally