Your question is a little confusing. Is it a mbox folder on a local machine or a folder on a remote machine?

In case of the former, you may not want to process each message line by line, to be fast. The messages are separated by lines starting with 'From '. But how do you know which messages to delete? Using MailBox, you could write

script: while(my $msg = Mail::Message->read(\*STDIN)) { $msg->write if $want_to_keep_it; } ./script <large >smaller

That's not the best way to process folders, but most memory preserving.

In case of a remote folder, you can open it using MailBox. It is a lazy implementation: only the messages you touch will be dowloaded. If you only touch the header, then only the header is downloaded. Even for large folders, memory consumption may stay in limits.

Sometimes, you should process a file in batches: download and process a few, than reopen the folder and process another few. In any case, if you have huge sets of data, your code become more complicated.

Concluding: as author of MailBox, I didn't receive any complaints about installation or test problems from you. That means that the (maybe) misfunction of the module is your problem! Make it my problem!


In reply to Re: Re: Re: mail box cleanup by markov
in thread mail box cleanup by PastisALo

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.