Re: $head->get issues possibly.

Mark Overmeer <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.mail-box
Organization MARKOV Solutions
Message-ID <[email protected]>
* Roderick A. Anderson ([email protected]) [040406 19:17]:
> Reference the $msg->date method mentioned in another message.  The docs 
> don't say what the format is of the returned value.  Well it does say as a 
> string.  :-)

$msg->date is short for $msg->head->get('date'), and may return undef


>    While looking around I also noticed the $msg->timestamp method.  What 
> is the format of the returned value?

$msg->head->timestamp is the parsed version of the date.  $msg->timestamp
is a little smarter.  I have updated its docuemtation into:

  =method timestamp
  Get a good timestamp for the message, doesn't matter how much work it is.
  The value returned is compatible with the platform dependent result of
  function time().

> Of course I'm slowly remembering why I used the head object instead of 
> the message object.  Since I'm parsing SPAM folders I didn't want to read 
> the whole thing into memory just to get the From and Date.

It doesn't work that way.  Each message is represented by 3 objects:
  - a Mail::Message, grouping Head and Body
  - a Mail::Message::Head
  - a Mail::Message::Body

Head and Body can be 'lazy', dependent on option flags but also on the
folder type.  When processing large folders, $msg->destruct may help: it
cleans-out memory occupied by the Head and Body objects.  Still, it 
may be wise to restart the application for (for instance) every 1000
processed messages.

>    I am pulling size information -- for the user -- and setting proper 
> dates etc. so the messages can be expunged after so many days.  Does the 
> require having the whole message in memory?

Depends.  Modifying message content is never a really smart idea, although
sometimes unavoidable.
Why not use Maildir or MH folder format and simply remove all messages
older a certain time by checking their file's mtime?
   find maildir/* -type f -mtime +8 -exec rm {} \;
Or are you not so lucky, not on UNIX/Linux?
-- 
               MarkOv

------------------------------------------------------------------------
drs Mark A.C.J. Overmeer                                MARKOV Solutions
       [email protected]                          [email protected]
http://Mark.Overmeer.net                   http://solutions.overmeer.net
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.