Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: Trimming a mailbox

by chrestomanci (Priest)
on Feb 13, 2012 at 13:25 UTC ( #953458=note: print w/replies, xml ) Need Help??

in reply to Trimming a mailbox

As thargas dramatically pointed out, parsing the date externally is risky, and should be unnecessary. Are you sure it is faster? How did you benchmark or profile it?

Instead there are are a number of modules on CPAN for the purpose. I have had most success with HTTP::Date, and there is also Date::Parse

Another approach you could use would be to switch your mailbox to use maildir format, and then each email is in a different file and the date on each file will match the received date, so a simple find invocation will remove old file.

Replies are listed 'Best First'.
Re^2: Trimming a mailbox
by oko1 (Deacon) on Feb 13, 2012 at 18:16 UTC

    Actually, it's not risky at all - as long as it's validated. I am indeed sure that it's faster, since I benchmarked it by trying it with several modules against a 20MB mailbox. Most of them couldn't handle the variety of date formats, as I'd already mentioned. The two that could were much slower than using 'date'.

    As to the advice to change to maildir... thanks, but I absolutely despise maildir for a variety of reasons. I was actually looking for advice on the program design/methodology (although bug-killing is certainly welcome); if you have any comments about that, they'd be most welcome.

    I hate storms, but calms undermine my spirits.
     -- Bernard Moitessier, "The Long Way"

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://953458]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2018-05-26 08:41 GMT
Find Nodes?
    Voting Booth?