Problem with Mail::Message::Head::Delayed and timestamp()

Eric Dorland <[email protected]> Tue, 24 May 2005 13:23:36 -0400
Newsgroups gmane.comp.lang.perl.modules.mail-box
Message-ID <[email protected]>
--+HP7ph2BbKc20aGI
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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 =3D 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 =3D 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.=20


--=20
Eric Dorland <[email protected]>
ICQ: #61138586, Jabber: [email protected]
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+=20
O? M++ V-- PS+ PE Y+ PGP++ t++ 5++ X+ R tv++ b+++ DI+ D+=20
G e h! r- y+=20
------END GEEK CODE BLOCK------

--+HP7ph2BbKc20aGI
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFCk2MYYemOzxbZcMYRAos3AJ9T4DXeRCatS64ok8K9Uwtbf8Rg2gCeMJ11
rfFXflFTarUtMm5zJOlvBcw=
=2nYP
-----END PGP SIGNATURE-----

--+HP7ph2BbKc20aGI--