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*


In reply to RE: PineTOC by splinky
in thread PineTOC by Tally

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.