logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

Problem with Mail::Message::Head::Delayed and timestamp(): msg#00002

Subject: Problem with Mail::Message::Head::Delayed and timestamp()
Hi,

I'm writing a little mail archiving program in perl, and I've run into
a little snag/bug with Mail::Box. My program, in essence, grabs a
bunch of messages from a mailbox and grabs their timestamps, and
copies them into different mailboxes based on their timestamp. I was
testing it with mboxes and everything was working great. Then I tried
some Maildirs and I ran into a problem, no timestamp was being
returned by timestamp(). For Maildirs, Mail::Box uses
Mail::Message::Head::Delayed for the headers object, so the headers
are only read when they are needed. That's fine, but if you look at
the Code for Mail::Message::timestamp

sub timestamp()
{   my $head = shift->head or return;
    $head->recvstamp || $head->timestamp;
}

For reasons I don't understand, in a boolean context,
Mail::Message::Head::Delayed objects evaluate to false. So the line
"my $head = shift->head or return;" always returns if the head object
hasn't been realized yet (which is the case in my code, since the
first thing I do with a message is grab it's timestamp). I can get
around this for now by doing a $message->head->load, but I don't think
this is the desired behavior. 


-- 
Eric Dorland <eric.dorland@xxxxxxxxxxxxxx>
ICQ: #61138586, Jabber: hooty@xxxxxxxxxx
1024D/16D970C6 097C 4861 9934 27A0 8E1C  2B0A 61E9 8ECF 16D9 70C6

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS d- s++: a-- C+++ UL+++ P++ L++ E++ W++ N+ o K- w+ 
O? M++ V-- PS+ PE Y+ PGP++ t++ 5++ X+ R tv++ b+++ DI+ D+ 
G e h! r- y+ 
------END GEEK CODE BLOCK------

Attachment: signature.asc
Description: Digital signature

<Prev in Thread] Current Thread [Next in Thread>