Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Trimming a mailbox

by chrestomanci (Priest)
on Feb 13, 2012 at 13:25 UTC ( [id://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?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://953458]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-24 02:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found