in reply to mail box cleanup

die "Whaaaaa?" if $! eq POSIX::EQUESTIONTOOVAGUE;

Define specific message in a mail box. A UNIX mbox format file? An IMAP mailbox? Have you looked at Mail::Box or Mail::Internet?

Replies are listed 'Best First'.
Re: Re: mail box cleanup
by PastisALo (Hermit) on Jan 22, 2004 at 22:45 UTC
    as you recommend I look Mail::Box , but there is problems with test failed when installing. its complex for me.

      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!