in reply to Reconstructing a Thunderbird address book from an mbox file

Since this seems to be a one-off project, the success of which can more or less be determined by hand, if this code works for you then fine. In general, I'd say you should use one of the many Mbox-handling modules on CPAN (Mail::MboxParser, Mail::Mbox::MessageParser or the 800-pound gorilla of all mailbox-handling modules Mail::Box). There are some corner cases which your code does not cover but these modules will help you avoid, for example, your above code adds addresses included in the From: lines of forwarded messages to your own address book, which may not be what you want. Similar thing for the email addresses, use Email::Address and you won't have to worry about stuff like commas in the quoted section of the name preceding an email address. And if you want to see what a complete email-parsing regular expression looks like then run

perl -MEmail::Address -e 'print $Email::Address::mailbox'

All dogma is stupid.

Replies are listed 'Best First'.
Re^2: Reconstructing a Thunderbird address book from an mbox file
by missingthepoint (Friar) on Dec 22, 2008 at 09:52 UTC

    Many thanks++

    I should have spent more time searching CPAN before writing that... I came across Mail::Box but thought 'too intimidating and probably overkill' and moved on. I might try a rewrite with Mail::MboxParser - it looks like what I wanted to use.

    You have a valid point regarding the one-off nature of this, but 'in general' one-offs tend not to be - hence my question :)

    perl -MEmail::Address -e 'print $Email::Address::mailbox'

    Bloody hell.

    :P


    Life is denied by lack of attention,
    whether it be to cleaning windows
    or trying to write a masterpiece...
    -- Nadia Boulanger