Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2024-04-25 14:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found